473,322 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

enter key

I am new to vb. I have visual studio .net 2003. I have a textbox the user
enters information into. After the information is entered, I have a button
they click and this executes code. However, I would like for them to be
able to press the enter key on the keyboard and the code for my button will
be executed. Any help would be much appreciated.

One more question. I have two labelboxes. I have written code that puts a
random number into each labelbox. My code is below.

If CheckBox2.Checked Then

Randomize(lblNum1.Text = CInt(Int((TextBox2.Text * Rnd()))))

ElseIf CheckBox1.Checked Then

lblNum1.Text = TextBox1.Text

Else

lblNum1.Text = CInt(Int((13 * Rnd())))

End If

If CheckBox3.Checked Then

lblNum2.Text = CInt(Int((TextBox3.Text * Rnd())))

ElseIf CheckBox4.Checked Then

lblNum2.Text = TextBox4.Text

Else

lblNum2.Text = CInt(Int((13 * Rnd())))

End If

When the code is executed for the first time it always puts the same two
numbers in each of the labelboxes. Why is it doing this. I even used the
randomize function and it still does this.

Thanks for any help.
Jul 21 '05 #1
2 1276
Steve wrote:
I would
like for them to be able to press the enter key on the keyboard and
the code for my button will be executed.
Set the AcceptButton property of the form to the name of the button.
One more question. I have two labelboxes. I have written code that
puts a random number into each labelbox. My code is below. <snip> When the code is executed for the first time it always puts the same
two numbers in each of the labelboxes. Why is it doing this. I even
used the randomize function and it still does this.


Just put randomize separately before each call to Rnd:

Randomize
lblNum1.Text = CInt(Int((TextBox2.Text * Rnd())))
Jul 21 '05 #2
Thanks.

"Leon Mayne [MVP]" <l.*********@uea.ac.uk> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Steve wrote:
I would
like for them to be able to press the enter key on the keyboard and
the code for my button will be executed.


Set the AcceptButton property of the form to the name of the button.
One more question. I have two labelboxes. I have written code that
puts a random number into each labelbox. My code is below.

<snip>
When the code is executed for the first time it always puts the same
two numbers in each of the labelboxes. Why is it doing this. I even
used the randomize function and it still does this.


Just put randomize separately before each call to Rnd:

Randomize
lblNum1.Text = CInt(Int((TextBox2.Text * Rnd())))

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: junk mail | last post by:
My friend is trying to code a small c program where he wants to force the user to press enter and only enter to continue. Currently he is using getchar() with a loop but you can type any number...
5
by: ewillyb | last post by:
Hi, ASP.NET has some interesting behavior when the user hits the Enter key. If there are multiple ASP:Buttons (rendered as HTML submits) on the form, when the user hits enter, the first button's...
15
by: Adam J. Schaff | last post by:
I have noticed that if a user closes a form via pressing return (either while the OK button has focus or if AcceptButton is set to OK for the form) then the "ENTER" keypress event fires ON THE...
6
by: Clark Sann | last post by:
Can someone help me understand what object should be used as the lock object? I've seen some programs that use Monitor.Enter(Me). Then, in those same programs, they sometimes use another object. ...
7
by: Marc | last post by:
Hi, I want my user to be able to rename a button control by selcting rename from a menu. This then opens a text box in which to enter the new name in. I want the button control to...
18
by: Zytan | last post by:
I want the same function to be run whether you press Enter or double click the listbox. It seems really verbose to write both handlers to both events everytime, even if they both call the same...
2
by: JWest46088 | last post by:
I want the user to enter information, such as names, and then I want to ask them after they entered the first name if they want to enter another name. How would I do that? This is what I have so...
7
by: Rotsey | last post by:
Hi, I am having a problem trying to select an item with the enter key. I want to work the combo with the keyboard. So when I use the down arrow to browse the list I want to then hit the...
24
by: MichaelK | last post by:
Who knows how to prevent submitting a form on the press Enter button before all fields on the form are filled up. People just enter the first field hit Enter and it submits the form and doing...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.