永发信息网

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

答案:2  悬赏:0  手机版
解决时间 2021-03-05 02:37
最好都能有。。
最佳答案
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哥哥帮你,对你好吧!也不搞点分来啊
全部回答
课程设计自己学着写,不懂,直接到网下搜源码改。。没人会花时间为你免费做一个课程设计 。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
血小板是细胞产物还是活细胞
鸿伟广告图文在哪里啊,我有事要去这个地方
赛尔号马尔活动有木有结束
沈阳全外教青少年英语课哪里比较好?
我从玉泉路到北京站做地铁要多长时间,我是6
侠盗猎车手:罪恶都市 怎么招小弟或保彯
浑浊的浑组什么词
长春必可成生物材料有限公司在哪里啊,我有事
除了A站B站P站还有什么站
假如你生活在明朝中后期,做纺织生意赚了很多
初中数学 有没有比较好的数学教辅书,要有难
气体分子的平均平动动能公式ε=3/2 kT,在什么
山西太原忻州河曲县有什么安全些的快捷酒店吗
丰田凯美瑞2.0与2.4哪个油耗比较低点
二建可以分两年考,那两次报名盖章是不是得同
推荐资讯
田山七粉和田山七哪一种好?
当一个女孩儿送你一粒扣子那代表什么???
单选题某位皇帝即位后,读《孟子》至“君之视
外地车走了(北京2环主路禁区)怎么处罚啊
mac game center在哪
显示器黑屏显示无信号怎么办
笨笨在计算15+12×
问道强化雷怪吃宠物成长丹是否有效??
双源高轿修理厂在什么地方啊,我要过去处理事
国营婚纱摄影旗舰店在哪里啊,我有事要去这个
卫滨区新乡益源健康体验中心地址在哪,我要去
家乐氏香脆麦米片 Special K
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?