作者yekome (/ \)
看板Visual_Basic
標題[VB6 ] 輸入一組答案
時間Fri Oct 31 20:03:58 2008
此程式為先設定一組答案(英文或數字都可)
之後再輸入去猜答案
答對會顯示出來
答錯會要再輸入一次
現在無法設定答案 請幫我看哪裡有錯
Dim answer As String
Dim enteranswer As String
Dim number As Integer
Dim firsttime As Integer
Private Sub Form_Activate()
Print "請設定正確答案"
firsttime = 0
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 32 Then
Print "按下space"
End If
If firsttime = 0 Then
If KeyAscii = 13 Then
firsttime = 1
Cls
Else
amswer = answer + Chr(KeyAscii)
Print answer
End If
Else
enteranswer = enteranswer + Chr(KeyAscii)
number = number + 1
If number = Len(answer) Then
If enteranswer = answer Then
Print "正確答案"
Else
Cls
Print "請重新輸入答案"
enteranswer = ""
number = 0
End If
End If
End If
End Sub
--
※ 發信站: 批踢踢實業坊(ptt.cc)
※ 編輯: yekome 來自: 220.130.232.109 (10/31 20:04)
1F:→ MOONRAKER:VB中也有cls好用嗎!? 10/31 20:10
2F:推 EShensh:拿 QB 的劍斬 VB 的官? XDD 11/01 01:53
3F:→ MOONRAKER:一時之間還以為除了form.print以外還有form.cls :︴ 11/01 13:05
4F:推 fumizuki:Cls是屬於Form的成員沒錯啊 11/01 15:45
5F:→ fumizuki:還有錯字呢... 11/01 15:47
6F:→ yekome:我執行有錯耶 在第一次要設定答案時無法輸入 可幫我看看嗎 11/01 19:31