C语言程序设计 (英文打字练习)

最好都能有。。
2024-12-05 03:56:03
推荐回答(2个)
回答(1):

Option Explicit
Dim speed, right, wrong, keynum As Integer '定义速度,正确次数,错误次数,击键次数
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Const SND_ASYNC = &H1
Dim rtn As LongSub letterInit() '初始化每个字母
lbl_letter.Caption = Chr(Int(Rnd * 26) + 97) '随机产生字母,如果要产生大写字母只要把97改成65即可
speed = Int(Rnd * 100 + 200)
lbl_letter.Left = Int(Rnd * (Form1.Width - lbl_letter.Width)) '随机产生字母出现的位置
lbl_letter.Top = lbl_score.Height
End SubPrivate Sub Command1_Click()
letterInit
lbl_score.Caption = "成绩: " & 0 & " 分" & " 错误: " & 0 & " 个" & " 正确率: " & 0 & "%"
Timer1.Enabled = True '启动定时器
Timer2.Enabled = True
Timer1.Interval = 100
Timer2.Interval = 1000
'隐藏命令按钮
Command1.Visible = False
Command2.Visible = False
lbl_time.Caption = 120 & " 秒"
End SubPrivate Sub Command2_Click()
Unload Me
End SubPrivate Sub Form_KeyPress(KeyAscii As Integer)
keynum = keynum + 1 If Chr(KeyAscii) = lbl_letter.Caption Then '判断所按键位是否与产生的字母相符
letterInit
rtn = sndPlaySound(App.Path & "\right.wav", SND_ASYNC)
right = right + 1
Else
rtn = sndPlaySound(App.Path & "\wrong.wav", SND_ASYNC)
wrong = wrong + 1
End If
lbl_score.Caption = "成绩: " & right & "分" & " 错误: " & wrong & " 个" & " 正确率: " & Int(right / keynum * 100) & "%" If KeyAscii = 27 Then
Timer1.Enabled = False
Timer2.Enabled = False
lbl_score.BackColor = vbYellow
lbl_score.Caption = "成绩: " & right & "分" & " 错误: " & wrong & " 个" & " 正确率: " & Int(right / keynum * 100) & "%" & " 按任意键继续"
Else
lbl_score.BackColor = vbGreen
Timer1.Enabled = True
Timer2.Enabled = True
End If
End SubPrivate Sub Form_Load()
Form1.Left = (Screen.Width - Form1.Width) / 2
Form1.Top = (Screen.Height - Form1.Height) / 2
Form1.BorderStyle = 1
Form1.BackColor = vbBlack
Form1.Caption = "英文打字练习程序"
Command1.Default = True
Command1.Caption = "开始"
Command2.Caption = "退出"
'设置lbl_letter中显示的字符的字体、样式、字号,请同时调整lbl_letter的大小与字符大小相等
With lbl_letter.Font
.Name = "宋体"
.Size = 20
.Bold = True
End With
lbl_letter.ForeColor = vbYellow
lbl_letter.BackColor = Form1.BackColor
lbl_score.BackColor = vbGreen
lbl_score.Alignment = 0
lbl_score.Caption = "敲回车键开始打字练习,按ESC键暂停"
lbl_time.BackColor = lbl_score.BackColor
lbl_time.Alignment = 2
lbl_time.Caption = "时间120秒"
Timer1.Enabled = False
Timer2.Enabled = False
Randomize '初始化
End SubPrivate Sub Timer1_Timer()
lbl_letter.Top = lbl_letter.Top + speed
If lbl_letter.Top >= Form1.Height Then
letterInit
End If
End Sub Private Sub Timer2_Timer()
lbl_time.Caption = Val(lbl_time.Caption) - 1 & " 秒"
If Val(lbl_time.Caption) <= 0 Then '判断时间是否已经用完
Timer1.Enabled = False
Timer2.Enabled = False
lbl_letter.Caption = ""
Select Case (right * (right / keynum))
Case Is <= 80
MsgBox "成绩: 不及格! 不过别灰心,请多多练习!", vbOKOnly, "练习结束!"
Case Is <= 100
MsgBox "成绩: 及格! 还要继续加油努力啊!", vbOKOnly, "练习结束!"
Case Is <= 120
MsgBox "成绩: 良!再加加油你就可以成为高手了!", vbOKOnly, "练习结束!"
Case Is >= 150
MsgBox "成绩: 优秀! 太棒了,恭喜你再也不会为打字发愁了!", vbOKOnly, "练习结束!"
End Select Command1.Visible = True '命令按钮恢复为可见状态
Command2.Visible = True
right = 0
wrong = 0
keynum = 0
End If
End Sub哥哥帮你,对你好吧!也不搞点分来啊

回答(2):

课程设计自己学着写,不懂,直接到网下搜源码改。。没人会花时间为你免费做一个课程设计 。