帮我一个忙哦~~大哥哥们

tianyalangzi1985 2007-12-28 09:12:05
将从键盘上输入的一位数字翻译为对应的英文单词,若输入长度大于1且不是0—9之间的数字,则显示“输入错误,请重新输入”的信息。
...全文
45 点赞 收藏 3
写回复
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
lianzy 2007-12-28

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
回复
cike_1111 2007-12-28
看来看去....
好象楼主的题目好难揣摩啊!!

2楼(is me) 实现的目的是 在 text中 输入数字自动转英文 不知道是不是楼主要的...

1楼的代码我没明白干什么用....



回复
cike_1111 2007-12-28
材料:
1*text1

代码:


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

========================
运行效果: 该text完全符合楼主要求
1.输入非数字字符后给出提示
2.将输入的数字自动转换为英文
回复
发动态
发帖子
VB基础类
创建于2007-09-28

7450

社区成员

VB 基础类
申请成为版主
社区公告
暂无公告