Jump to content

Random insult generator!

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Demon

Demon

    Newbie

  • Members
  • PipPip
  • 18 posts
Hey first tutorial so I wanted to make it easy :w00t:

Basic explanation

This will use radio buttons and if statements to determine the outcome and get your insult using a message box.

Things you'll need:

As many radio buttons as you like depending on your number of choices.
Labels to show what the radio buttons will indicate.
A brain. (May be purchased at your local hardware store for 9.95)

Placement

Some thing like this:

Offense level [Label 1]
Low [Radio button 1]
Medium [Radio button 2]
High [Radio button 3]

New column:

How bad are their teeth [Label 2]
Eh not too bad [Radio button 4]
Terrible [Radio button 5]
Makes little children cry [Radio button 6]

Now for the code

You want to see what they chose using the checked command like so:

If RadioButton1.Checked & RadioButton4.Checked Then

Meaning if Radio button 1 [insult level low] and Radio button 4 [Their teeth aren't too bad] Then do something. To do this we'll use a message box like so:

MsgBox("Your teeth are okayish")

Then we use end if

Our code being:

If Radiobutton1.Checked & Radiobutton4.checked Then

Msgbox("Your teeth are okayish")

End if

And viola you have a random insult generator.

#2
Tanzim

Tanzim

    Newbie

  • Members
  • Pip
  • 4 posts
This is very basic, but it may help newbies learn how to use if statements in their programs:thumbup:

#3
Demon

Demon

    Newbie

  • Members
  • PipPip
  • 18 posts
That's what I aimed to do =P

#4
Jarryd

Jarryd

    Learning Programmer

  • Members
  • PipPipPip
  • 63 posts
this would be so much easier and more understandable if you were running case's...

for example:

        Dim randomInsult As String

        randomInsult = Int(Rnd() * 4)


        Select Case randomInsult

            Case 1

                MsgBox("How bad are their teeth")

            Case 2

                MsgBox("Eh not too bad")

            Case 3

                MsgBox("Terrible")

            Case 4

                MsgBox("Makes children cry")

        End Select