vendredi 27 mars 2015

My Visual Basic random joke and color generator doesn't work. Why is this?

Ok so I'm making a program and I have a splash screen that I want to always generate one of the jokes I've made for it and one of the colors I've put there. I want it to generate them randomly, not so that a certain joke has a certain color, but so that they're both just completely random. Though when I start this program, it only shows a form with no text and the color I set it to in the designer. I also have a label on the form called lblJoke. The form is of course called frmSplash.




Public Class frmSplash
Dim rn As New Random
Dim n As Integer
Dim joke As String
Dim daBBColor As System.Drawing.Color
Dim daFFColor As System.Drawing.Color



Private Sub frmSplash_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
lblJoke.Text = joke
Jokes()
Colors()
lblJoke.Text = joke
End Sub

Sub Colors()
n = rn.Next(1, 4)
Select Case n
Case 1
daBBColor = Color.Aquamarine
daFFColor = Color.Black
Case 2
daBBColor = Color.Bisque
daFFColor = Color.Black
Case 3
daBBColor = Color.DeepPink
daFFColor = Color.White
Case 4
daBBColor = Color.Black
daFFColor = Color.White
End Select
End Sub

Sub Jokes()
n = rn.Next(1, 5)
Select Case n
Case n = 1
joke = "What do you call a pile of cats? - A meowntain."
Case n = 2
joke = "Why did Beethoven kill his chicken? - It kept saying 'Bach, Bach, Bach, Bach'."
Case n = 3
joke = "What do blondes and beer bottles have in common? - They're both empty from the neck up."
Case n = 4
joke = "Why couldn't the blonde add 10 and seven on a calculator? - She couldn't find the 10 key."
Case n = 5
joke = "What is the definition of diplomacy? - The ability to tell a person to go to hell in such a way that they look forward to the trip."
End Select
End Sub


End Class





Aucun commentaire:

Enregistrer un commentaire