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

熱點內容
武漢征源程序員多少工資 瀏覽:498
發布保潔信息去哪個平台 瀏覽:866
小程序貝克的秘密掃碼怎麼沒反應 瀏覽:529
單片機程序燒寫怎麼辦 瀏覽:489
安邦的產品有哪些 瀏覽:471
哪個軟體可以看到京東數據 瀏覽:407
怎麼阻止頭條跳出小程序 瀏覽:560
生物計算機以什麼作為數據 瀏覽:591
怎麼收集財產信息 瀏覽:852
maze技術屬於哪個公司 瀏覽:29
做引產是怎麼個程序 瀏覽:237
甘肅清香型白酒代理費用是多少 瀏覽:419
沒事給領導發什麼信息 瀏覽:680
臨期產品怎麼做引流 瀏覽:18
為什麼會反感小程序 瀏覽:446
結息交易130元能貸多少 瀏覽:836
交易貓買王者怎麼買 瀏覽:25
微信小程序攜程怎麼登錄app 瀏覽:400
裝潢材料代理哪個好做 瀏覽:874
貓咪心超數據怎麼看 瀏覽:45