Random Quote
Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts
Page 1 of 1
I want to display a random quote in my program at startup(4 quotes)
Can anyone give me a starter to work from? I can't seem to do it right :?
Can anyone give me a starter to work from? I can't seem to do it right :?
Thy this:
Code: Select all
I refined the code to just use a Label control.
Public Class frmMain
Private Sub btnGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerate.Click
Dim cExistingQuestions As New Collection
Dim bValidQuestion As Boolean = False
Label1.Text = randomPWQuestion(randomNumber(0, 8))
cExistingQuestions.Add(Label1.Text, Label1.Text)
End Sub
Private Function generateRandom(ByVal iLowerBound As Integer, ByVal iUpperBound As Integer) As Integer
Randomize()
Dim r As New Random
Return r.Next(iLowerBound, iUpperBound)
End Function
Public Function randomNumber(ByVal iLower As Integer, ByVal iUpper As Integer) As Integer
Return generateRandom(iLower, iUpper)
End Function
Private Function randomPWQuestion(ByVal iRandom As Integer) As String
Select Case iRandom
Case 0
Return "Where did you meet your spouse?"
Case 1
Return "What was the name of your first school?"
Case 2
Return "Who was your childhood hero?"
Case 3
Return "What is your favorite pastime?"
Case 4
Return "What is your favorite sports team?"
Case 5
Return "What is your father's middle name?"
Case 6
Return "What was your high school mascot?"
Case 7
Return "What make was your first car or bike?"
Case 8
Return "What is your pet's name?"
End Select
Return "Where did you meet your spouse?"
End Function
End Class
3 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023