在 keypress 事件里判断不行?
private sub text1_keypresss(assicc as long)
if assicc=13 then 
debug.print "按了回车键"
end if
end sub

解决方案 »

  1.   

    Private Sub text1_KeyPress(KeyAscii As Integer)
    if KeyAscii =13 then 
    debug.print "按了回车键"
    end ifEnd Sub
      

  2.   

    在keypress中不是每按一个键就会被触发一资吗?什么会不能重复间断?
    可以的嘛。
      

  3.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
       If KeyAscii = &HD Then
          ' 对数据进行处理
          ' ......
       End If
    End Sub
      

  4.   

    是这样的吗?可是按了enter以后没反应啊,没有显示
    Private Sub Text3_KeyPress(keyascii As Integer, i As Integer)
        
        If keyascii = 13 Then
        Form2.Text3(i) = Hex(Val(Text3(i + 7)))//这句有问题吗?
        End If
    End Sub
      

  5.   

    Private Sub Text3_KeyPress(keyascii As Integer, i As Integer)
        
        If keyascii = 13 Then
        Form2.Text3(i) = Hex(Val(Text3(i + 7)))//这句有问题吗?
        Form2.Visible=True 
        End If
    End Sub
      

  6.   

    This example uses the Hex function to return the hexadecimal value of a number.Dim MyHex
    MyHex = Hex(5)   ' Returns 5.
    MyHex = Hex(10)   ' Returns A.
    MyHex = Hex(459)   ' Returns 1CB.
      

  7.   

    private sub text1_keypresss(assicc as long)
    if assicc=13 then 
    …………
    …………
    end if
    end sub
      

  8.   

    Hex转换后的数值能直接显示在文本框里吗?
    比如:Text1.text=Hex(10)  ' 可以吗?
      

  9.   

    如果截面不是很复杂的话:你可以在截面上添加一个commandbutton,然后设置该button的default为true,然后在该button中处理数据,
    如果界面复杂的话也可以这样处理,不过要添加一个标志位来判断目前是不是在编辑文本框。代码如下:
    Dim txteditflag As Boolean
    Private Sub Command1_Click()
    If txteditflag = True Then
       MsgBox "you click return!"
       txteditflag = False
       Command1.SetFocus
    End If
    End SubPrivate Sub Form_Load()
       txteditflag = False
       Me.KeyPreview = True
       Command1.Default = True
    End SubPrivate Sub text1_GotFocus()
      txteditflag = True
    End SubPrivate Sub Text1_LostFocus()
       txteditflag = True
    End Sub
      

  10.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii = vbKeyReturn Then
            Text1.Text = Hex(Val(Text1.Text))
            KeyAscii = 0
        End If
    End Sub
      

  11.   

    下面代码我通过的呀
    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii = vbKeyReturn Then
            Text1.Text = Hex(Val(Text1.Text))
        End If
    End SubText1能显示的
      

  12.   

    可是我就是显示不了,按回车键后没有任何反应
    Private Sub Text3_KeyPress(keyascii As Integer, i As Integer)
        '判断回车键是否按下
        If keyascii = &HD Then
        keyascii = 0
        Text3(i).Text = Hex(Val(Text3(i + 7).Text))
        '将10进制数转化为16进制数
        End If
    End Sub
    难道是我定义的数组有问题?
      

  13.   

    Private Sub Text3_KeyPress(keyascii As Integer, i As Integer)
        '判断回车键是否按下
        If keyascii = &HD Then
        keyascii = 0
        Text3(i).Text = Hex(Val(Text3(i + 7).Text))
        '将10进制数转化为16进制数
        End If
    End Sub
    i 最大为多少
    若 dim text3(4) as string 
    点击text3(3)时
    则Text3(i).Text = Hex(Val(Text3(i + 7).Text))
    变为:Text3(3).Text = Hex(Val(Text3(10).Text))
    超出数组定义
      

  14.   

    这个问题不存在,i没有超出定义
    现在主要是这段代码根本没有检测到“Enter”键按下
    我用Msgbox试过了