Solved

Display Message in TextBox until it is selected to type

Posted on 2011-02-22
6
739 Views
Last Modified: 2012-05-11
I want to display message in the TextBox until it is selected by the user to type in some value.

EX:
I want to display message "Enter your ID" in the Text Box until it is selected by the user to enter the ID.

How would i achieve this using Excel VBA.
0
Comment
Question by:srikanthv2322
  • 2
  • 2
6 Comments
 
LVL 5

Accepted Solution

by:
roger_karam earned 334 total points
ID: 34957441
You want to use the inputbox function:


    strID= InputBox(Prompt:="Enter your ID.", Title:="ID input", Default:="ID Please")

-RK
0
 
LVL 50

Assisted Solution

by:Dave Brett
Dave Brett earned 166 total points
ID: 34957483
To force the user to enter an ID you would validate the entry as below

This test looks for a simple entry, then reflgas the message with an error title if nothing was entered

You could take it further, say to validate a 5 digit code etc

Cheers

Dave
Sub GetId()
    Dim strMsg As String
    Dim strTitle As String
redo:
    strId = InputBox("Enter your ID", strTitle)
    If Len(strId) = 0 Then
        strTitle = "Error: You must enter an ID to proceed!"
        GoTo redo
    End If
End Sub

Open in new window

0
 
LVL 5

Assisted Solution

by:roger_karam
roger_karam earned 334 total points
ID: 34957529
Hey srikanthv2322,

I think I might have misunderstood the question. Do you want a textbox that has Enter your ID written on it, but when you select the textbox it goes blank?

If you have a form with a Text Box, what you want to do is set the Textbox Text control to "Enter your ID" then have the following in the vba code for the text box. It will make it go blank when the text box is selected if it has Enter your ID written on it.

Private Sub TextBox1_Enter()

If TextBox1.Value = "Enter your ID" Then
TextBox1.Value = ""
End If

End Sub

-RK
0
 
LVL 50

Expert Comment

by:Dave Brett
ID: 35194530
As roger_karam re-interpreted his orginal comment, and it isn't completely clear what the Asker wanted, then I think a point split for
 - roger_karam's comment #34957529  (250 points)
- brettdj's comment #34957483  (250 points)

would be more appropriate

Cheers

Dave
0
 
LVL 24

Expert Comment

by:broomee9
ID: 35225349
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now