Change the blink rate of the caret

Change the blink rate of the caret

You can retrieve and change the blink rate of the flashing caret inside TextBox controls through a couple of simple API functions:

Private Declare Function SetCaretBlinkTime Lib "user32" (ByVal wMSeconds As _    Long) As LongPrivate Declare Function GetCaretBlinkTime Lib "user32" () As Long

For example you can double the current blink rate using this code

Dim saveBlinkTime As LongsaveBlinkTime = GetCaretBlinkTime()SetCaretBlinkTime saveBlinkTime * 2

Remember that the blink time is a system-wide setting, so you should revert it to its original value when whenever you switch to another application (which requires subclassing techniques, however) or at least when the current form unloads:

Private Sub Form_Unload(Cancel As Integer)    ' reset blink time before exiting    SetCaretBlinkTime saveBlinkTimeEnd Sub


About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist