|
-
Jan 26th, 2013, 03:58 AM
#1
Thread Starter
Registered User
How do I clear a textbox by just clicking on it? Also, a database(?) related question
Hello!
It's my first time to post on this forum, and I'm looking forward to post more as time passes. 
But for now, I would like to ask a couple of questions...
First, how do I clear the contents of a Textbox by just clicking on it?
Second, a more complicated one... I would like to create a VB program where I would just input a number (say, an student ID number) and the details of the student would be displayed. I know it has something to with databases, but I'm not really sure. I have only basic knowledge of VB, and I am using an older version.
Thank you in advance.
Cheers.
-
Jan 26th, 2013, 07:29 AM
#2
Re: How do I clear a textbox by just clicking on it? Also, a database(?) related ques
First question:
Text1.Text = vbNullString
Second question:
open a new thread with specific info.
-
Jan 26th, 2013, 07:51 AM
#3
Re: How do I clear a textbox by just clicking on it? Also, a database(?) related ques
First question:
I will be sticking with
Text1.Text = ""
I have been rubbing garlic on my neck for decades, and never had a vampire bite.
I have been using "" for decades, and never had a problem.
I don't know if a switch to vbNullString will cause any problems, but why should I take the risk ? (I don't give a hang about tiny savings in time or space)
Regarding the second Question, be sure to mention what version of VB you are using, for two reasons -
1) It can effect what DB accessing method you can use (DAO vs ADO)
2) We can harass you, until you upgrade to VB6
Rob,
PS In case you are very new to VB, you may need to know the event to use. EG -
Private Sub Text1_Click()
Text1.Text = ""
End Sub
And depending on the context you are using this, there are other events, that can be used, instead.
You may care to widen your explanation of what will be happening ?
Last edited by Bobbles; Jan 26th, 2013 at 07:57 AM.
-
Jan 26th, 2013, 10:27 AM
#4
Re: How do I clear a textbox by just clicking on it? Also, a database(?) related ques
Rather than clearing the data when you click on it you might want to consider highlighting the data when the text box gets focus. This will allow the user to clear the data with the first key stroke or retain the data or part of the data as they wish.
The method depends on the version of VB you are using.
VB6 or earlier would be
Code:
Text1.SelStart=1
Text1.SelLength=Len(Texr1.Text)
VB7 amd newer would be
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|