鼠标悬停的代码是?当鼠标悬停于文本框上方是选中文本框中的所有内容的代码是什么?

解决方案 »

  1.   

    给你写了一个例子,你自己根据实际需要修改吧。Option ExplicitPrivate Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function ReleaseCapture Lib "user32" () As LongDim bFirstClick As BooleanPrivate Sub Form_Load()
        bFirstClick = True
    End SubPrivate Sub Text1_Click()
        If bFirstClick Then
            Text1.Text = ""
            bFirstClick = False
        End If
    End SubPrivate Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = 0 Then
            With Text1
                If (X < 0) Or (Y < 0) Or (X > .Width) Or (Y > .Height) Then
                    .ForeColor = vbBlack
                    ReleaseCapture
                Else
                    .ForeColor = vbBlue
                    SetCapture .hwnd
                End If
            End With
        End If
    End Sub
      

  2.   

    看这个是不是你想要的
    Private Sub Text1_Click()
        If Text1.Text = "Text1" Then
            Text1.Text = ""
        End If
    End SubPrivate Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        
        Text1.SelStart = 0
        Text1.SelLength = Len(Text1.Text)
        
    End Sub