请问如何在一个文本框中输入字母时显示其它数字内容?如输入A对应显示1,B对应显示2,C对应显示3, 也就是在文本框键入ABC时文本框内显示的却是123,请问如何实现??
新手没分可给,请高手友情帮忙一下....

解决方案 »

  1.   

    Option Explicit
    Private Sub Form_Load()
    Text1.Text = ""
    End SubPrivate Sub Text1_Change()
    If Text1.Text <> "" Then
        If IsNumeric(Text1.Text) = False Then
            Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
            Text1.SelStart = Len(Text1.Text)
        End If
    End If
    End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii > 96 And KeyAscii < 106 Then
            Text1.SelStart = Len(Text1.Text)
            Text1.SelText = KeyAscii - 96
        End If
    End Sub
      

  2.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    Select Case KeyAscii
        Case Asc("A")
            KeyAscii = Asc("1")
        ……………………后面自己写
    End Select
    End Sub
      

  3.   

    谢谢各位了...还想请教一下,楼上的代码都是按键一一对应的,那我想按下"A"键显示"123",按下"B"键显示"456",...
    也就是按下AB键显示的是"123456",这个如何实现??
      

  4.   

    我已经找到方法了,谢谢各位了
    Private Sub text1_KeyDown(KeyCode As Integer, Shift As Integer) '
    If KeyCode = 65 Then Text1.Text = Text1.Text & "123" '65为A的键值If KeyCode = 66 Then Text1.Text = Text1.Text & "456" '66为B的键值End Sub