在用vb做的一个窗口上,有txtd(),是text控件数组,当光标停留在文本框上以后,可以按F8键来实现文件将文本的内容复制下来,我应该怎么做呀,谢谢各位大虾
然后还能拷贝到想要拷贝到的地方

解决方案 »

  1.   

    Option Explicit
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
    Private Const EM_GETLINE = &HC4
    Private Const WM_GETTEXT = &HD
    Private Const WM_GETTEXTLENGTH = &HE
    '使用剪贴版或者发送消息Private Sub Form_Load()
    Form1.KeyPreview = True
    End SubPrivate Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
    Dim cLong As Long
    Dim astr As String * 256If KeyCode = 119 Then
    '使用消息方式
        cLong = SendMessage(Text1.hwnd, WM_GETTEXTLENGTH, 0, vbNull)
        SendMessage Text1.hwnd, WM_GETTEXT, cLong + 1, astr
        Text2.Text = astr
    '剪贴版方式
    'Clipboard.SetText Text1.Text
    'Text2.Text = Clipboard.GetText
    End If
    End Sub
      

  2.   

    我也来凑热闹,^_^Private Sub txtd_KeyUp(Index As Integer, KeyCode As Integer, Shift As Integer)
        If KeyCode = vbKeyF8 Then
            Clipboard.SetText txtd(Index).Text
        End If
    End Sub