rnm89 Posted April 5, 2003 Posted April 5, 2003 I am working a project where I need 3 radio boxes radiobox1 (Happy) radiobox2 (sad) radiobox3 (angry) when radiobox1(happy) is clicked and generate (button1) pressed it generates a random number, based on that number a HAPPY sentence will be displayed in textbox1.text If radiobox2 (sad) button1 will generate a SAD sentence. like wise for radiobox3 (angry) This is what I have under each radiobox ' Randomize control for radiobox1 Randomize() Dim A As Integer A = Int(Rnd() * 5) + 1 If A = 1 Then TextBox1.Text = "happy 1" If A = 2 Then TextBox1.Text = "Happy 2" If A = 3 Then TextBox1.Text = "Happy 3" If A = 4 Then TextBox1.Text = "Happy 4" If A = 5 Then TextBox1.Text = "Happy 5" ' End Randomize control The same applies for radiobox2 & 3 except that the sentence is either angry or sad. Here is where I am stuck. I cannot firgure how to get button1 (Generate) to start the process. I am new to vb.net and have 2 books, I have tried different things including if, elseif. I am just brain dead. Quote
Leaders Squirm Posted April 6, 2003 Leaders Posted April 6, 2003 Move your code into a procedure which handles the Click event for the button. The only changes which need to be made would be some code to determine which optionbutton is selected. Quote Search the forums | Still IRCing | Be nice
rnm89 Posted April 6, 2003 Author Posted April 6, 2003 this is where I'm at I wrote this code into the button1 field If RadioButton1.Checked = True Then TextBox1.Text = ("box1") If RadioButton2.Checked = True Then TextBox1.Text = ("box2") If RadioButton3.Checked = True Then TextBox1.Text = ("box3") I am trying to get the sub routine to work with this Quote
Leaders Squirm Posted April 6, 2003 Leaders Posted April 6, 2003 Inside the If Then...End If blocks, place your happy/sad/angry generating code. If RadioButton1.Checked Then 'Generate happy ElseIf RadioButton2.Checked Then 'Generate sad ElseIf RadioButton3.Checked Then 'Generate angry End If Quote Search the forums | Still IRCing | Be nice
rnm89 Posted April 6, 2003 Author Posted April 6, 2003 Thank you That worked. I don't understand why I keep having problems with the elseif tag. I truly appreciate the help. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.