作者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