Make your own free website on Tripod.com

Hide And Show Text Box Caret

'Add 1 Text Box and 1 Check Box to your form.
'Uncheck the Check Box to hide Text1 Caret. Check it again to return the caret.

'Insert the following code to your form:

Private Declare Function HideCaret Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ShowCaret& Lib "user32" (ByVal hwnd As Long)

Private Sub CheckCaret()
If Check1.Value = vbChecked Then
ShowCaret (Text1.hwnd)
Else
HideCaret (Text1.hwnd)
End If
End Sub

Private Sub Form_Load()
Check1.Value = 1
End Sub

Private Sub Text1_Change()
CheckCaret
End Sub

Private Sub Text1_GotFocus()
CheckCaret
End Sub

Go Back