• Log in or sign up for an account here: https://www.sythe.org/login

Randomize Letters.

  • Thread starter Thread starter SwiftYx
  • Start date Start date
S

SwiftYx

Guest
I've just started a I.T course at college it's pretty basic stuff but not having used VB before only for very simple thing's i haven't got a clue on some stuff.

I'm having to create a Who Wants To Be A Millionaire style game as part of a mini project, I'm putting my questions together as i go along but before i can continue any further i have to get the life lines working.

I have 50/50 working by disabling two of the wrong answers.

Ask the audience displays a form from excel but i was wondering if it's possible that when i click on a command button instead of putting Result1.Show it's possible to randomize what form would pop up?

For the phone a friend i wanted to use a drop down box with a few names in it that when chosen would display a letter between A, B, C & D.

If any of this is possible can someone please help, Sorry for the noobishness.
 
^^^ Good Luck ^^^

I also whipped up this code just for your phone a friend. :p
Code:
Dim StrValue As Integer
Dim CData As Integer
Dim CDefaultAnswer As String
Dim CFinalAnswer As String
Private Sub Command1_Click()
'Declares actual answer
CDefaultAnswer = Label1.Caption 'You can change that to your answer to be held.
'-Declare Dificulties
'You can declare more names with an (ElseIf) but keep the range from 1-3
If Combo1.Text = "Bob" Then 'Example Name (You can Change)
GetData 1 'Highest Chance to get correct
ElseIf Combo1.Text = "Sarah" Then 'Example Name (You can Change)
GetData 2 'Low Chance to get correct
ElseIf Combo1.Text = "Sam" Then 'Example Name (You can Change)
GetData 1
Else
GetData 3 'Completely Random Chance to get correct
End If
'-Start answering
If Combo1.Text = "Original Combo Text" Then 'meaning if the user hasent picked someone to call...
MsgBox "Please choose someone to call", vbCritical
Exit Sub
End If
If CFinalAnswer = CDefaultAnswer Then
MsgBox (CFinalAnswer) & " (Correct)"
Else
MsgBox (CFinalAnswer) & " (Incorrect)"
End If
End Sub

Public Function GetData(Level)
GetAnswer
If Level = 1 And Not CFinalAnswer = CDefaultAnswer Then
GetAnswer
ElseIf Level = 2 And CFinalAnswer = CDefaultAnswer Then
GetAnswer
Else
'Simply do noting and answer
End If
End Function
Public Function GetAnswer()
'Randomization Code
Randomize
StrValue = Int(5 * Rnd) 'Number 5 = Max Number + 1 or 4
'Start Answering
If StrValue = 1 Then
CFinalAnswer = "A"
ElseIf StrValue = 2 Then
CFinalAnswer = "B"
ElseIf StrValue = 3 Then
CFinalAnswer = "C"
ElseIf StrValue = 4 Then
CFinalAnswer = "D"
End If
End Function
 
Your phone a friend should not be purely random either. It should give the correct response 50-70% of the time I think.
 
<3 n4n0
Discord Verified
Two Factor Authentication User
Community Participant
Spam Forum Participant
Sythe's 10th Anniversary
Sythe Awards 2011 Winner
Your phone a friend should not be purely random either. It should give the correct response 50-70% of the time I think.

Yes I agree, because most of the time when they phone a friend, the friend is right.
 
Valentine's Singing Competition Winner
Sythe Awards 2015 Winner
Sythe Awards 2016 Winner
Sythe Awards 2020 Winner
Member of the Month Winner
MushyMuncher
Gohan has AIDS
Extreme Homosex
World War 3
I'm LAAAAAAAME
Discord Verified
Off Topic Participant
A long way of doing it could be with arrays:

Code:
Dim Letters As String
Dim strOut As String

    Letters = Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z")
    Randomize
    strOut = Int(26 * Rnd)

Or a little easier:
Code:
Chr(Rand(45, 90))
^^Picks a random upper case letter.
 
duelarena.gg
Back
Top