比如说我想在textbox输入某些内容后,用回车将输入的内容存入数据库。但是textbox好像没有这个方法?!

解决方案 »

  1.   

    是有的,但是應該在keyDown中.
    如:
    Private Sub txtABC_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = vbKeyReturn Then
             '這裡就可以寫你的代碼了。。
        End If
    End Sub
      

  2.   

    Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
        If KeyCode=13 then
            msgbox"你按下了回车键"
      End IF
    End Sub
      

  3.   

    Private Sub txtABC_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = 13 Then
            '.....
        End If
    End Sub
      

  4.   

    Private Sub txtABC_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = vbKeyReturn Then
            if trim(TxtABC.text)<>empty then
                Call SavatextToDb(trim(TxtABC.text))
                DoEvents   '因為數據庫寫動作,將系統權交給別的處理線程。可以不要這句。
            end if
        End If
    End Subprivate Sub SavatextToDb(byval Lstr_TxtAbc.Text)
        dim .......
        
        On Error .....    '這裡可以寫代碼了
    End sub 
      

  5.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
     If (KeyAscii = 13) Then
       Me.Caption = Text1.Text
     End If
    End Sub