I might try a Lable whose visibility is controlled by the TextBox's MouseMove event.
Create a Class module named clsHoverLabel with this code in it.
' in clsHoverLabel
Public WithEvents myTextBox As MSForms.TextBox
Public WithEvents myLabel As MSForms.Label
Dim ShowMe As Boolean
Private Function CreateLabel() As MSForms.Label
Set CreateLabel = myTextBox.Parent.Controls.Add("forms.Label.1")
With CreateLabel
.AutoSize = False
.BackColor = vbYellow
.BackStyle = fmBackStyleOpaque
.BorderStyle = fmBorderStyleSingle
.Width = myTextBox.Width
.Visible = False
.Caption = myTextBox.Text
.AutoSize = True
.Top = myTextBox.Top + myTextBox.Height + 5
.Left = myTextBox.Left + 10
End With
Set myLabel = CreateLabel
End Function
Property Set TextBox(inBox As MSForms.TextBox)
Set myTextBox = inBox
CreateLabel
End Property
Property Get Visible() As Boolean
Visible = myLabel.Visible
End Property
Property Let Visible(inVal As Boolean)
myLabel.Visible = inVal And (Len(myTextBox.Text) > 0)
End Property
Private Sub myLabel_Click()
myLabel.Visible = False
End Sub
Private Sub myTextBox_Change()
With myLabel
.AutoSize = False
.Caption = myTextBox.Text
.Width = myTextBox.Width * 2
.AutoSize = True
.AutoSize = False
.Width = WorksheetFunction.Max(.Width, myTextBox.Width)
.Visible = (Len(myTextBox.Text) > 0) And Me.Visible
End With
End Sub
Private Sub myTextBox_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
With myTextBox
If X < 2 Or Y < 2 Or (.Width - X) < 2 Or (.Height - Y) < 2 Then
Me.Visible = False
Else
Me.Visible = True
End If
End With
End Sub
Then put code like this in the userform's code module
Dim LabeledTextbox As clsHoverLabel
Private Sub UserForm_Initialize()
Set LabeledTextbox = New clsHoverLabel
Set LabeledTextbox.TextBox = TextBox1
End Sub
Bookmarks