Radiobox problem

rnm89

Newcomer
Joined
Apr 1, 2003
Messages
20
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.
 
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.
 
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
 
Inside the If Then...End If blocks, place your happy/sad/angry generating code.

Visual Basic:
If RadioButton1.Checked Then
    'Generate happy
ElseIf RadioButton2.Checked Then
    'Generate sad
ElseIf RadioButton3.Checked Then
    'Generate angry
End If
 
Thank you

That worked. I don't understand why I keep having problems with the elseif tag.

I truly appreciate the help.
 
Back
Top