|
-
Mar 26th, 2010, 11:27 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Trigger TextBox When Form Opens???
I am creating a form and I have a label that will display the user's name, but what I need to do it trigger a text box when the application opens that will allow the user to type in their name and then assign that value to the label in my form. How do I trigger the text box and assign the value to my label? My label is named lblStudent. Can anyone help me with this?
-
Mar 26th, 2010, 11:38 PM
#2
Lively Member
Re: Trigger TextBox When Form Opens???
Try this:
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
Label1.Caption = Text1
End Sub
-
Mar 27th, 2010, 12:01 AM
#3
Thread Starter
Addicted Member
Re: Trigger TextBox When Form Opens???
When I tried to add this code, both the Label1 and Text1 say they are not declared and there is an error when I try to run the script. I don't have a text box on my form, I just have the label. I need to have a text box trigger when the form opens, like a pop up I guess, and then the user can put in their name and then the value of the text box gets saves to the label (lblStudent). I'm new to this type of coding. Can you be a little more detailed?
-
Mar 27th, 2010, 12:38 AM
#4
PowerPoster
Re: Trigger TextBox When Form Opens???
Try adding a TextBox and a Label, both named: Text1 and Label1. To use the code posted in Post #2.
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
-
Mar 27th, 2010, 01:28 AM
#5
Re: Trigger TextBox When Form Opens???
 Originally Posted by twilitegxa
When I tried to add this code, both the Label1 and Text1 say they are not declared and there is an error when I try to run the script. I don't have a text box on my form, I just have the label. I need to have a text box trigger when the form opens, like a pop up I guess, and then the user can put in their name and then the value of the text box gets saves to the label (lblStudent). I'm new to this type of coding. Can you be a little more detailed?
Welcome to the forums...
I think, InputBox() is really what you want..!
Code:
Private Sub Form_Load()
lblStudent.Caption = InputBox("Enter your name:")
End Sub
...
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Mar 28th, 2010, 05:02 AM
#6
Thread Starter
Addicted Member
Re: Trigger TextBox When Form Opens???
 Originally Posted by akhileshbc
Welcome to the forums...
I think, InputBox() is really what you want..!
Code:
Private Sub Form_Load()
lblStudent.Caption = InputBox("Enter your name:")
End Sub
... 
That sound more like what I am needing, but when I tried your code, I received this error:
Error 1 'Caption' is not a member of 'System.Windows.Forms.Label'.
Can you help? I don't know what to do.
-
Mar 28th, 2010, 05:34 AM
#7
PowerPoster
Re: Trigger TextBox When Form Opens???
What kind of Visual Basic or Visual Studio are you using. Because that sounds like a .NET version of Visual Basic!! If I'm not mistaken??? Or your ActiveX control, hasn't been registered, or that you have to add it into your project!!
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
-
Mar 28th, 2010, 07:25 AM
#8
Re: Trigger TextBox When Form Opens???
 Originally Posted by twilitegxa
That sound more like what I am needing, but when I tried your code, I received this error:
Error 1 'Caption' is not a member of 'System.Windows.Forms.Label'.
Can you help? I don't know what to do.
You are not using VB6. In that language, labels have a caption property. In VB.NET, they have a text property, so it would be
Code:
lblStudents.Text = Whatever
Moved To VB.NET
-
Mar 28th, 2010, 10:39 AM
#9
Addicted Member
Re: Trigger TextBox When Form Opens???
I think you use vs8
beside in vs8 we dont have any caption for label1 in vs8 it's text
it's the same code that akhileshbc said
1-make a label1
just copy these in your code page
Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = InputBox("Enter your name:")
End Sub
End Class
Last edited by Pc Monk; Mar 28th, 2010 at 10:47 AM.
-
Mar 29th, 2010, 02:09 AM
#10
New Member
Re: Trigger TextBox When Form Opens???
 Originally Posted by akhileshbc
Welcome to the forums...
I think, InputBox() is really what you want..!
Code:
Private Sub Form_Load()
lblStudent.Caption = InputBox("Enter your name:")
End Sub
... 
i was having same problem
ty for you're help
-
Mar 29th, 2010, 11:26 AM
#11
Addicted Member
Re: Trigger TextBox When Form Opens???
Ok how about this
in form1 you make one textbox and in form2 you have your label
in startup first you load form1 and the user type his name and then form2 coming up with the label that have the value of textbox in form1
i think you should try this
-
Mar 29th, 2010, 02:03 PM
#12
Thread Starter
Addicted Member
Re: Trigger TextBox When Form Opens???
 Originally Posted by Pc Monk
I think you use vs8
beside in vs8 we dont have any caption for label1 in vs8 it's text
it's the same code that akhileshbc said
1-make a label1
just copy these in your code page
Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = InputBox("Enter your name:")
End Sub
End Class
Thank you so much! This example did the trick!
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
|