Log in

View Full Version : How do i do like this in Microsoft Visual Basic 2005 Express Edition


salman1
20th November 2007, 01:02
Hi, i m newbie in programing and my teacher gave me homework which i need little bit help so how do make this text box like this like when we click it will allow to click and they don't have to to Delete stuff and enter anything. sorry for my bad english. Thanks...

http://maxupload.com/img/EB7D53A0.jpg

Guest
20th November 2007, 03:28
Your problem statement makes no sense. Please write down exactly what the teacher asked for.

I do have some advice, though. Get a good book and start studying it. And ask the teacher to get you started in the right direction. That is what they are there for.

salman1
20th November 2007, 03:39
Ok i understand that happens. Ok let me re try it. i want to do text box like this shows in image. like when some 1 or i click it That txt in text box should be gone because when i do it i have use BACKSPACE key to erase then re write. so what text box property does that for me? Thanks..

JohnnyMalaria
20th November 2007, 03:42
I think salman1 means that the predefined text ('first name') should disappear as soon as the textbox is clicked for the first time.

It depends on the language. For VC++, it depends on whether ATL, MFC or just plain WIN32 are used. For VB, it's easier but the principle is the same:

Trap the MouseDown, MouseClick or whatever the language-specific event is called and, if it's the first time for that particular textbox, delete the text.

I created this in Excel's VBA in about 2 minutes (the forum mangles the formatting):

Dim FirstClick As Boolean

Private Sub TextBox1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If FirstClick Then
TextBox1.Value = ""
FirstClick = False
End If
End Sub

Private Sub UserForm_Initialize()
FirstClick = True
End Sub

It assumes a single textbox on a simple form.

salman1
20th November 2007, 03:54
^ Yes. but i try that code but didn't worked :( Thanks. can u tell me what property ??

JohnnyMalaria
20th November 2007, 04:22
What language are you using?

Zach
20th November 2007, 05:58
If you do his homework for him, Johnny, how will he ever learn?


That said, oh, man, I wish I had the internet when I was growing up. :p All that wasted time studying I had to do all on my own. :D

salman1
20th November 2007, 14:13
^ It's just little Suggestion By the way i m using English because by brother help me some time with it

Guest
20th November 2007, 14:23
^ It's just little Suggestion By the way i m using English because by brother help me some time with it LOL, I think Johnny meant which computer language are you coding in.

Johnny, he mentioned Visual Basic in his thread title.

DarkZell666
5th December 2007, 13:09
I created this in Excel's VBA in about 2 minutes (the forum mangles the formatting):
You can use the "code" tag instead of the "quote" tag for that sort of thing ;) The text keeps it's formatting.