7,785
社区成员




Option Explicit
Dim en(0 To 9) As String
Const str = "0123456789"
Private Sub Command1_Click()
If Len(Text1.Text) <> 1 Then
MsgBox "请输入0 to 9的数字"
Text1.SetFocus
Exit Sub
ElseIf InStr(str, Text1.Text) = 0 Then
MsgBox "请输入0 to 9的数字"
Text1.SetFocus
Exit Sub
Else
MsgBox en(CInt(Text1.Text))
Text1.SetFocus
End If
End Sub
Private Sub Form_Load()
en(0) = "zero"
en(1) = "one"
en(2) = "two"
en(3) = "three"
en(4) = "four"
en(5) = "five"
en(6) = "six"
en(7) = "seven"
en(8) = "eight"
en(9) = "nine"
End Sub
Private Sub Form_Load()
Text1 = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then
kyeascii = 8
Else
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0: MsgBox "请输入0-9的数字"
Select Case KeyAscii
Case (49)
Text1.Text = Text1 & "One": KeyAscii = 0: Text1.SelStart = Len(Text1)
Case (50)
Text1.Text = Text1 & "Two": KeyAscii = 0: Text1.SelStart = Len(Text1)
Case (51)
Text1.Text = Text1 & "Three": KeyAscii = 0: Text1.SelStart = Len(Text1)
Case (52)
Text1.Text = Text1 & "Four": KeyAscii = 0: Text1.SelStart = Len(Text1)
Case (53)
Text1.Text = Text1 & "Five": KeyAscii = 0: Text1.SelStart = Len(Text1)
Case (54)
Text1.Text = Text1 & "Six": KeyAscii = 0: Text1.SelStart = Len(Text1)
Case (55)
Text1.Text = Text1 & "Seven": KeyAscii = 0: Text1.SelStart = Len(Text1)
Case (56)
Text1.Text = Text1 & "Eight": KeyAscii = 0: Text1.SelStart = Len(Text1)
Case (57)
Text1.Text = Text1 & "Nine": KeyAscii = 0: Text1.SelStart = Len(Text1)
Case (48)
Text1.Text = Text1 & "Zero": KeyAscii = 0: Text1.SelStart = Len(Text1)
End Select
End If
End Sub