Dim digit_on_command()
Dim shift_on As Boolean
Dim pre_press As Integer
Private Sub Command1_Click(Index As Integer)
Static s As String * 1
If Index = 10 Then
If Len(Text1) >= 1 Then
Text1 = Left(Text1, Len(Text1) - 1)
pre_press = 10
End If
ElseIf Index = 11 Then
shift_on = Not shift_on
pre_press = 11
ElseIf Index = 9 Then
If shift_on = False Then
Text1 = Text1 & digit_on_command(Index)
Else
Text1 = ""
pre_press = 9
End If
Else
If shift_on = False Then
Text1 = Text1 & digit_on_command(Index)
Else
Timer1.Enabled = False
If pre_press = Index Then
s = Chr((Asc(s) + 1))
If s > Right(str_on_command(Index), 1) Then s = Left(str_on_command(Index), 1)
Text1 = Left(Text1, Len(Text1) - 1) & s
Else
s = Left(str_on_command(Index), 1)
Text1 = Text1 & s
pre_press = Index
End If
Timer1.Enabled = True
End If
End If
End Sub
Private Sub Form_Load()
digit_on_command = Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0")
str_on_command = Array("-", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz", "")
Dim sDisplay As String
For i = 0 To 9
Command1(i).Caption = digit_on_command(i) & vbCrLf & str_on_command(i)
Next i
Command1(10).Caption = "C"
Command1(10).FontSize = 32
Command1(11).Caption = vbCrLf & "abc"
Command1(11).Picture = LoadPicture(App.Path + "\pic1.gif")
shift_on = False
pre_press = 11
End Sub
Private Sub Timer1_Timer()
pre_press = 11
Timer1.Enabled = False
End Sub
這個是我們的上機實驗之壹。