導航:首頁 > 軟體知識 > 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程序怎麼編文字相關的資料

熱點內容
測量後如何出數據 瀏覽:963
女生輸液怎麼發信息安慰 瀏覽:524
產品拍攝創作思路怎麼寫 瀏覽:706
儋州國產化妝品有哪些代理商加盟 瀏覽:420
招代理什麼靠譜 瀏覽:288
nba2k20端游怎麼交易巨星 瀏覽:562
域名在哪裡可以代理 瀏覽:205
藍牙鍵盤聊微信如何發出信息 瀏覽:679
員工怎麼保持技術領先 瀏覽:890
數據幀中包含mac地址還有哪些 瀏覽:771
全人才小程序是做什麼的 瀏覽:27
青島萬通證券用哪個軟體交易 瀏覽:384
交大電子信息專業如何 瀏覽:738
河北保定相親市場在哪裡 瀏覽:726
沒有核心技術怎麼走出來 瀏覽:827
哪些產品不需要生產許可證 瀏覽:303
馬自達總代理怎麼做 瀏覽:513
鋼材銷售代理屬於什麼行業 瀏覽:404
普通超時空什麼時候交易 瀏覽:379
互聯網技術與應用學的是什麼 瀏覽:564