Question

I know this is an odd one, but is there a way to emulate the placeholder text functionality in VB6? If not, does anyone know of a good OCX control I could get somewhere that will do this? I'm sure it can be programmed in with a set of functions to do this, just looking for something already done.

The placeholder I'm asking about isn't the "formatting" in VB6, but like the text you see on a webform instead of a label for instance.

The text inside of a text box that tells you what information goes in that box, or provides and example of the information you want the user to enter into that particular box.

Any help is greatly appreciated, as always.

Was it helpful?

Solution 2

Let's see if I understand what you want correctly. You want a textbox that says (for example): "First Name" inside of it to show users what to enter?

This can be accomplished by setting the text value to "First Name" in design mode. Then, on the GotFocus event, you delete the text inside giving the user a blank textbox to enter their info.

To make it more user friendly, you can have grey text when it's just a label, and black text when its the users entry. You can also test for the text color so you don't delete the user's info if they reenter a textbox.

OTHER TIPS

It sounds like you want Cue Banners. These also work on ComboBox controls.

Private Const CBM_FIRST As Long = &H1700&
Private Const CB_SETCUEBANNER As Long = CBM_FIRST + 3
Private Const ECM_FIRST As Long = &H1500&
Private Const EM_SETCUEBANNER As Long = ECM_FIRST + 1

Private Declare Function SendMessage Lib "user32" Alias "SendMessageW" ( _
    ByVal hWnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    ByVal lParam As Long) As Long

Private Sub SetCueBannerTXT(ByVal TextBox As TextBox, ByVal CueText As String)
    SendMessage TextBox.hWnd, EM_SETCUEBANNER, 0, StrPtr(CueText)
End Sub

Private Sub SetCueBannerCBO(ByVal ComboBox As ComboBox, ByVal CueText As String)
    SendMessage ComboBox.hWnd, CB_SETCUEBANNER, 0, StrPtr(CueText)
End Sub

Note To use this API, you must provide a manifest specifying Comclt32.dll version 6.0.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top