请问这个小程序用VB如何编译?

来源:百度知道 编辑:UC知道 时间:2024/09/24 17:19:44
启动时显示数字1,按一下键盘空格变为2,以此类推,最大99,到达数字九十九以后再按空格键又变成数字1,就这么简单,有人会编么?
谢谢,不过我想要记分牌那样的,两位,最初显示是01,边框可以修饰的,请问可以做到么?

Private Sub Form_Load()
Text1.Text = 1
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 32 Then
Text1.Text = Val(Text1.Text) + 1
If Val(Text1.Text) > 99 Then Text1.Text = 1
End If
End Sub

测试通过

光标放到文本框上,按空格
Dim i As Integer

Private Sub Form_Load()
i = Format(1, "00")
Text1.Locked = True
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 32 Then
i = Format(i + 1, "00")
Text1.Text = Format(i, "00")
End If
If i >= 99 Then i = Format(0, "00")
End Sub
想要界面美观,最好加图片,

Private Sub Form_Load()
Text1.Text = "01"
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 32 Then
Text1.Text = format(Val(Text1.Text) + 1,"00")
If Val(Text1.Text) > 99 Then Text1.Text