Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7072971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:52:24+00:00 2026-05-28T05:52:24+00:00

We have a userform with multiple textboxes and we would like to build something

  • 0

We have a userform with multiple textboxes and we would like to build something similar to the link image below, in terms of showing what the user should input in each text box:

http://d2o0t5hpnwv4c1.cloudfront.net/426_formsBestPractices/comments.png

The “default” text would disappear once the user starts typing (as opposed than once the user “lands” cursor within the textbox.

Also, if nothing gets entered within the textbox the default text would not be submitted and a blank would be used.

Can this be done?

Any suggestions will be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:52:24+00:00Added an answer on May 28, 2026 at 5:52 am

    Can I ask why you want the default text to dissapear once a user changes the text and not once they enter the textbox?

    This is not what most users will expect, I think it will be slightly confusing for some and wouldn’t recommend it. The user will most likely try and delete the old text before typing their new text creating extra work.

    I would use something like this:

    Const sNameDefault As String = "Your Name Here"
    Const sEmailDefault As String = "Your Email Here"
    
    Private Sub UserForm_Initialize()
        Me.TextBox1.Text = sNameDefault
        Me.TextBox2.Text = sEmailDefault
    
        CommandButton1.SetFocus
    End Sub
    
    '// TextBox1 - Name
    Private Sub TextBox1_Enter()
        With Me.TextBox1
            If .Text = sNameDefault Then .Text = vbNullString
        End With
    End Sub
    
    Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
        With Me.TextBox1
            If .Text = vbNullString Then .Text = sNameDefault
        End With
    End Sub
    
    '// TextBox2 - Email
    Private Sub TextBox2_Enter()
        With Me.TextBox2
            If .Text = sEmailDefault Then .Text = vbNullString
        End With
    End Sub
    
    Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
        With Me.TextBox2
            If .Text = vbNullString Then .Text = sEmailDefault
        End With
    End Sub
    
    Private Sub CommandButton1_Click()
        Dim sName As String, sEmail As String
    
        '// Get Name
        If Me.TextBox1.Text = sNameDefault Then
            sName = vbNullString
        Else
            sName = Me.TextBox1.Text
        End If
    
        '//  Get Email
        If Me.TextBox2.Text = sEmailDefault Then
            sEmail = vbNullString
        Else
            sEmail = Me.TextBox2.Text
        End If
    
        MsgBox ("Your Name: " & sName & vbNewLine & " Your Email:" & sEmail)
    
        Unload Me
    End Sub
    

    The above example is simply a userform with two textbox’s and a commandbutton. Clicking inside the textbox will clear the default text. If the user enters nothing clicking another textbox or control will cause the default text to be added back. Once the command button is clicked the code will return blank if the default text remains.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In excel vba I have added a commandbutton to userform... like below Set ctrl
I have a vba userForm that has 36 buttons on it. I would like
I have a user controller. It has three methods for listing users, showing a
I have a userform that I have created that contains a number of TextBoxes.
I currently have a ModelForm set up in Django, but would like to make
I have an image in a userform which displays a pre-existing chart, according the
I have to display a column chart in a user form in VBA. Exporting
I have a requirement wherein I need to display on a User form, a
I have a UserForm class which has a select list populated from a related
I have added a ListBox to a SHEET (not to a UserForm) I did

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.