最近发现很对人需要打字程序的代码,新作了一个,还有些小功能可以自己补充。
ZIP发不上来,只能让大家自己复制下去了。
Option ExplicitSub cswz() '产生位置Randomizewz = Rnd() * (Picture1.Width - 200)End SubSub cszm()RandomizeIf nd = 1 Thenzm = Chr(Int(26 * Rnd + 65))'Label1(0).Caption = Chr(Int((90 - 65 + 1) * Rnd + 65)) '产生一个介于65到90之间的随机数ElseIf nd = 2 Thenzm = Chr(Int(58 * Rnd + 65))Elsezm = Chr(Int(75 * Rnd + 48))End IfEnd SubPrivate Sub Command1_Click()df = 0Command4.Visible = FalseCommand1.Visible = Falsesdsd '调用产生速度设定值Timer1.Interval = sd1syt = 200Picture1.SetFocuscswz '调用产生位置子程序Label1(0).Left = wzcswz '调用产生位置子程序Label1(1).Left = wzcswz '调用产生位置子程序Label1(2).Left = wzcswz '调用产生位置子程序Label1(3).Left = wzcswz '调用产生位置子程序Label1(4).Left = wzcswz '调用产生位置子程序Label1(5).Left = wzcszm '调用产生字母子程序Label1(0).Caption = zmcszm '调用产生字母子程序Label1(1).Caption = zmcszm '调用产生字母子程序Label1(2).Caption = zmcszm '调用产生字母子程序Label1(3).Caption = zmcszm '调用产生字母子程序Label1(4).Caption = zmcszm '调用产生字母子程序Label1(5).Caption = zmTimer1.Enabled = True ' 激活Time1控件Timer2.Enabled = True ' 激活Time2控件Label3.Caption = "当前得分:" & dfLabel4.Caption = "剩余时间:" & sytLabel2.Caption = "当前难度等级:" & ndLabel5.Caption = "当前速度等级:" & sdEnd SubPrivate Sub Command2_Click()EndEnd SubPrivate Sub Command4_Click()Form2.ShowEnd SubPrivate Sub Form_Load()RandomizeTimer1.Enabled = False ' Time1控件失效Timer2.Enabled = False ' Time2控件失效Command1.Visible = FalseEnd SubPrivate Sub Picture1_KeyPress(KeyAscii As Integer)If Chr(KeyAscii) = Label1(0).Caption Thendf = df + 1BeepLabel3.Caption = "当前得分:" & dfcszmcswzLabel1(0).Left = wzLabel1(0).Caption = zmLabel1(0).Top = 0ElseIf Chr(KeyAscii) = Label1(1).Caption Thendf = df + 1BeepLabel3.Caption = "当前得分:" & dfcszmcswzLabel1(1).Left = wzLabel1(1).Caption = zmLabel1(1).Top = 0ElseIf Chr(KeyAscii) = Label1(2).Caption Then df = df + 1BeepLabel3.Caption = "当前得分:" & dfcszmcswzLabel1(2).Left = wzLabel1(2).Caption = zmLabel1(2).Top = 0ElseIf Chr(KeyAscii) = Label1(3).Caption Then df = df + 1Label3.Caption = "当前得分:" & dfcszmcswzBeepLabel1(3).Left = wzLabel1(3).Caption = zmLabel1(3).Top = 0ElseIf Chr(KeyAscii) = Label1(4).Caption Then df = df + 1BeepLabel3.Caption = "当前得分:" & dfcszmcswzLabel1(4).Left = wzLabel1(4).Caption = zmLabel1(4).Top = 0ElseIf Chr(KeyAscii) = Label1(5).Caption Then df = df + 1BeepLabel3.Caption = "当前得分:" & dfcszmcswzLabel1(5).Left = wzLabel1(5).Caption = zmLabel1(5).Top = 0End IfEnd SubPrivate Sub Timer1_Timer()Label1(0).Top = Label1(0).Top + Rnd * 300 Label1(1).Top = Label1(1).Top + Rnd * 300 Label1(2).Top = Label1(2).Top + Rnd * 300 Label1(3).Top = Label1(3).Top + Rnd * 300 Label1(4).Top = Label1(4).Top + Rnd * 300 Label1(5).Top = Label1(5).Top + Rnd * 300 If Label1(0).Top > Picture1.Height Then cszmcswzLabel1(0).Left = wzLabel1(0).Caption = zmLabel1(0).Top = 0End IfIf Label1(1).Top > Picture1.Height Then cszmcswzLabel1(1).Left = wzLabel1(1).Caption = zmLabel1(1).Top = 0End IfIf Label1(2).Top > Picture1.Height Then cszmcswzLabel1(2).Left = wzLabel1(2).Caption = zmLabel1(2).Top = 0End IfIf Label1(3).Top > Picture1.Height Then cszmcswzLabel1(3).Left = wzLabel1(3).Caption = zmLabel1(3).Top = 0End IfIf Label1(4).Top > Picture1.Height Then cszmcswzLabel1(4).Left = wzLabel1(4).Caption = zmLabel1(4).Top = 0End IfIf Label1(5).Top > Picture1.Height ThencszmcswzLabel1(5).Left = wzLabel1(5).Caption = zmLabel1(5).Top = 0End IfEnd SubPrivate Sub Timer2_Timer() '剩余时间扣除计时syt = syt - 1 '扣除剩余个数中的一个Label4.Caption = "剩余时间:" & sytIf syt <= 0 ThenTimer1.Enabled = False ' 剩余个数小于等于0的时候结束练习'Label1.Caption = "" '不显示字母' Label6.Caption = ""Select Case dfCase Is <= 80MsgBox vbCrLf + "别放弃,再来一次!" ' 显示信息框Case Is < 120MsgBox vbCrLf + "成绩不错,加油!"Case Is < 150MsgBox vbCrLf + "再努力做的更好一些!"Case Is > 180MsgBox vbCrLf + "好厉害!最高分呀!"End SelectCommand4.Visible = TrueTimer1.Enabled = FalseTimer2.Enabled = FalseLabel1(0).Caption = ""Label1(1).Caption = ""Label1(2).Caption = ""Label1(3).Caption = ""Label1(4).Caption = ""Label1(5).Caption = ""Label1(0).Top = 0Label1(1).Top = 0Label1(2).Top = 0Label1(3).Top = 0Label1(4).Top = 0Label1(5).Top = 0End IfEnd Sub设定窗口代码:Option ExplicitPrivate Sub Command1_Click()If Option1.Value = True Thennd = 1ElseIf Option2.Value = True Thennd = 2Elsend = 3End IfIf Option4.Value = True Thensd = 1ElseIf Option5.Value = True Thensd = 2Elsesd = 3End IfForm2.Hidemand1.Visible = TrueEnd SubPrivate Sub Form_Load()Option1.Value = TrueOption4.Value = TrueEnd SubPrivate Sub Form_Unload(Cancel As Integer)Form2.HideEnd Sub模块代码:Option ExplicitPublic nd, sd, sd1 As Integer '定义公共变量难度和速度Public df, syt, wz As Integer '定义公共变量分数剩余时间Public zm As String '定义随机产生的字母Public Sub sdsd() '定义速度值If sd = 1 Thensd1 = 800ElseIf sd = 2 Thensd1 = 500Elsesd1 = 300 End If End Sub。