导航:首页 > 软件知识 > vb程序怎么编文字

vb程序怎么编文字

发布时间:2023-04-16 07:06:18

Ⅰ 用VB如何设计打字程序啊,各位大哥大姐帮帮忙啊。

添加控件.
command1 frame1 (label1……label6 timer1 timer2)

'窗体代码,测试好的,大概就是这样 稍微改下就可以实现你所说的功能
Option Explicit
Dim score As Integer
Dim speed As Integer

Sub init()
Label1.Caption = Chr(Int(Rnd * 26) + 49) ' / 设定Label1随机显示的字母
speed = Int(Rnd * 100 + 100) '/ 设定Label1随机显示字母的速度
Label1.Left = Int(Rnd * Frame1.Width) '/ 设定Label1代表字母出现的左边位置
Label1.Top = Frame1.Top '/ 设定Label1代表字母出现的顶部位置
End Sub

Sub init1()
Label6.Caption = Chr(Int(Rnd * 26) + 97) '/ 设定Label2随机显示的字母
speed = Int(Rnd * 100 + 100) '/ 设定Label2随机显示字母的速度
Label6.Left = Int(Rnd * Frame1.Width) ' / 设定Label2代表字母出现的左边位置
Label6.Top = Frame1.Top ' / 设定Label2代表字母出现的顶部位置
End Sub

Private Sub Command1_Click()
init ' /调用init子程序
Timer1.Enabled = True '/ 激活Time1控件
Timer2.Enabled = True '/ 激活Time2控件
Command1.Visible = False
Label5.Caption = 200
Label4.Caption = 0
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) = Label1.Caption Then ' /校验键盘输入字符和Label1显示的字符
init
score = score + 1 ' / 得分加1
Label4.Caption = score
End If
If Chr(KeyAscii) = Label6.Caption Then ' /校验键盘输入字符和Label2显示的字符
init1
score = score + 1
Label4.Caption = score '/ Label4控件显示得分情况
End If
End Sub

Private Sub Form_Load()
Randomize
Timer1.Enabled = False '/ Time1控件失效
Timer2.Enabled = False '/ Time2控件失效
End Sub

Private Sub Timer1_Timer()
Label1.Top = Label1.Top + speed
If Label1.Top > Frame1.Height Then ' /第一个字母超出屏幕范围的时候调用init子程序重新出现一个字母
init
End If
Label6.Top = Label6.Top + speed
If Label6.Top > Frame1.Height Then '/第二个字母超出屏幕范围的时候调用init1子程序重新出现一个字母
init1
End If
End Sub

Private Sub Timer2_Timer()
Label5.Caption = Val(Label5.Caption) - 1 '/ 扣除剩余个数中的一个
If Val(Label5.Caption) <= 0 Then
Timer1.Enabled = False '/ 剩余个数小于等于0的时候结束练习
Label1.Caption = "" ' / 不显示字母
Label6.Caption = ""
Select Case score
Case Is <= 80
MsgBox vbCrLf + "别放弃,再来一次!" '/ 显示信息框
Case Is < 120
MsgBox vbCrLf + "成绩不错,加油!"
Case Is < 150
MsgBox vbCrLf + "再努力做的更好一些!"
Case Is > 180
MsgBox vbCrLf + "好厉害!最高分呀!"
End Select
Command1.Visible = True
Label4.Caption = 0
Label5.Caption = 200
Timer1.Enabled = False
Timer2.Enabled = False
End If
End Sub

阅读全文

与vb程序怎么编文字相关的资料

热点内容
临期产品怎么做引流 浏览:18
为什么会反感小程序 浏览:445
结息交易130元能贷多少 浏览:836
交易猫买王者怎么买 浏览:25
微信小程序携程怎么登录app 浏览:400
装潢材料代理哪个好做 浏览:873
猫咪心超数据怎么看 浏览:44
个人信息变更报盘文件是什么意思 浏览:711
交易遇到瓶颈如何处理 浏览:196
什么叫有限元分析技术 浏览:923
从哪里了解征兵信息 浏览:196
医学核医学技术有什么区别 浏览:294
大兴区代理刑事律师事务所哪个好 浏览:537
士兵有什么技术 浏览:133
追梦格林被交易哪里了 浏览:549
怎么突出摄影技术 浏览:603
淮安博德建材批发市场在哪里 浏览:515
美甲小程序哪个好用 浏览:56
赛伍技术什么时间上市 浏览:328
闲时在家能做什么代理 浏览:424