By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,658 Members | 1,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,658 IT Pros & Developers. It's quick & easy.

enter key

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.