Welcome to Gaia! :: View User's Journal | Gaia Journals

 
 

View User's Journal

Report This Entry Subscribe to this Journal
My Journal Just a place for random jokes, drawings, stories, or whatever I feel like.


Zifnab of Pyran
Community Member
avatar
0 comments
Behold...
Wall of programming code

All green text are comments about what a specific part of the program does. This is all done in Visual Basic. I'm aware that it is a bit sloppy... but I will clean it up later if I ever want to do something with this thing again for another college class.
-------------------------------------------------------------------------------------------------------

Imports System.IO 'Initialize stream reading and writing
Public Class Form1

Dim Progress(19) As String 'Declare strng variables with 20 array entries
Dim Question(19) As String
Dim Answer1(19) As String
Dim Answer2(19) As String
Dim Answer3(19) As String
Dim Answer4(19) As String
Dim RealAnswer(19) As String
Dim usrName As String 'Declare string variable to accept user name.
Dim a As Integer = 0 'Start page counter
Dim i As Integer = 0 'Declare integer variables for counting loops through program and such
Dim j As Integer = 0 'Declare integer variables.
Dim k As Integer = 0 'Random counter in Submit loop
Dim l As Integer = 0 'k is used as correct answer counter
Dim r(3) As Double 'Declare double variable for use in random number generation for hint section.
Dim s(26) As Double 'Declare double variable for use in random number generation for Submit section.
Dim srZodiac As StreamReader = New StreamReader("Zodiac.txt" wink 'Open the file Zodiac.txt

'About menu commands.
Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
AboutBox1.ShowDialog()
End Sub

'Quit menu comands.
Private Sub QuitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitToolStripMenuItem.Click
Me.Close()
srZodiac.Close()
End Sub

'Contact menu comands.
Private Sub ContactToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ContactToolStripMenuItem.Click
End Sub

'Start commands
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
grpStartPage.Visible = False 'Hide opening group panel from view.
Select Case a
Case a = 0 'If a = 0, perform task.
usrName = txtUserName.Text 'Store text entered by user to usrName variable.
lblStartText.Text = "Greetings " 'Insert text into lblStartText.
lblStartText.Text &= usrName 'Concatinate usrName variable data into lblStartText, along with data found below.
lblStartText.Text &= " and enjoy the game."
btnStart.Text = "START" 'Change button title to START.
a = 1 'Set variable a to 1.
Case a = 1 'If a = 1, perform task.
grpStartPage.Visible = False
End Select
End Sub

'Hint commands
Private Sub btnHint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHint.Click
btnHint.Enabled = False 'Disable Hint Button to prevent continuous use.
Randomize() 'Randomize hints based upon where the answer is located.
r(j) = (CLng((Rnd()) * 3)) 'Create a randomly generated number between 0 and 2.
r(j) += 1 'Add one to the generated number.
If RealAnswer(i) = rdbAnswer1.Text Then 'Compare text stored in Answer1 variable to text in rdbAnswer1.text variable, outer if and else if statement.
If r(j) = 1 Then 'Check r(j) for which option to use, inner if and else if statement.
rdbAnswer2.Visible = False 'Hide specified radial buttons if condition is met.
rdbAnswer3.Visible = False
ElseIf r(j) = 2 Then 'If conditon was not met in first option, check second option of r(j).
rdbAnswer2.Visible = False
rdbAnswer4.Visible = False
ElseIf r(j) = 3 Then 'If condition was not met in second option, check third option of r(j).
rdbAnswer3.Visible = False
rdbAnswer4.Visible = False
End If 'Exit inner if statement.
ElseIf RealAnswer(i) = rdbAnswer2.Text Then 'Compare text stored in Answer2 variable to text in RealAnswer(i) variable if Answer1 was incorrect, outer if and else if statement.
If r(j) = 1 Then 'Check r(j) for which option to use, inner if and else if statement
rdbAnswer1.Visible = False
rdbAnswer3.Visible = False
ElseIf r(j) = 2 Then 'If conditon was not met in first option, check second option of r(j).
rdbAnswer1.Visible = False
rdbAnswer4.Visible = False
ElseIf r(j) = 3 Then 'If condition was not met in second option, check third option of r(j).
rdbAnswer3.Visible = False
rdbAnswer4.Visible = False
End If 'Exit inner if statement.
ElseIf RealAnswer(i) = rdbAnswer3.Text Then 'Compare text stored in Answer3 variable to text in RealAnswer(i) variable if Answer2 was incorrect, outer if and else if statement.
If r(j) = 1 Then 'Check r(j) for which option to use, inner if and else if statement
rdbAnswer1.Visible = False
rdbAnswer2.Visible = False
ElseIf r(j) = 2 Then 'If conditon was not met in first option, check second option of r(j).
rdbAnswer1.Visible = False
rdbAnswer4.Visible = False
ElseIf r(j) = 3 Then 'If condition was not met in second option, check third option of r(j).
rdbAnswer2.Visible = False
rdbAnswer4.Visible = False
End If 'Exit inner if statement.
ElseIf RealAnswer(i) = rdbAnswer4.Text Then 'Compare text stored in Answer4 variable to text in RealAnswer(i) variable if Answer3 was incorrect, outer if and else if statement.
If r(j) = 1 Then 'Check r(j) for which option to use, inner if and else if statement
rdbAnswer1.Visible = False
rdbAnswer2.Visible = False
ElseIf r(j) = 2 Then 'If conditon was not met in first option, check second option of r(j).
rdbAnswer1.Visible = False
rdbAnswer3.Visible = False
ElseIf r(j) = 3 Then 'If condition was not met in second option, check third option of r(j).
rdbAnswer2.Visible = False
rdbAnswer3.Visible = False
End If 'Exit inner if statement.
End If 'Exit outer if statement.
End Sub

'Quit commands
Private Sub btnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click
Me.Close()
srZodiac.Close()
End Sub

'Restart commands
Private Sub btnRestart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRestart.Click
grpStartPage.Visible = True
a = 0
i = 0
j = 0
k = 0
l = 0
btnHint.Enabled = True
srZodiac.Close()
End Sub

'Submit commands
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim strArray(7) As String 'Create a string array with 7 items in it (0 being first item, 6 being last item).
Dim strTemp As String
btnHint.Enabled = True 'Enable the hint button for use.
rdbAnswer1.Visible = True 'Make all radial buttons visible again.
rdbAnswer2.Visible = True
rdbAnswer3.Visible = True
rdbAnswer4.Visible = True
If srZodiac.Peek >= 0 Then 'Until stream reader reaches end of the file, do the following.
strTemp = srZodiac.ReadLine 'Pass srZodiac info to strTemp
strArray = Split(strTemp, ":" wink 'Split data file on colons for storing within the following items.
Progress(i) = strArray(0) 'Take text before first colon and store in Progress(i) variable, (i) used to recal specific data.
Question(i) = strArray(1) 'Take text between first and second colons and store in Question(i) variable, (i) used to recal specific data.
Answer1(i) = strArray(2) 'Take text between second and third colons and store in Answer1(i) variable, (i) used to recal specific data.
Answer2(i) = strArray(3) 'take text between third and fourth colons and store in Answer2(i) variable, (i) used to recal specific data.
Answer3(i) = strArray(4) 'Take text between fourth and fifth colons and store in Answer3(i) variable, (i) used to recal specific data.
Answer4(i) = strArray(5) 'Take text between fifth and sixth colons and store in Answer4(i) variable, (i) used to recal specific data.
RealAnswer(i) = strArray(6) 'Store text between the sixth colon and the new line character in RealAnswer(i) variable, (i) used to recal specific data.
Randomize() 'Initialize random number generator.
r(k) = (CLng((Rnd()) * 26)) 'Pick a random value for r(k) between the numbers 0 - 26.
r(k) += 1 'Add 1 to generated number.
lblAnswered.Text = Progress(i) 'Print ocurrance Progress(i) to lblAnswered
lblQuestion.Text = Question(i) 'Print ocurrance Question(i) to lblQuestion
Select Case r(k) 'Select case by randomly generated number stored in r(k).
Case Is = 1
rdbAnswer1.Text &= Answer1(i)
rdbAnswer2.Text &= Answer2(i)
rdbAnswer3.Text &= Answer3(i)
rdbAnswer4.Text &= Answer4(i)
Case Is = 2
rdbAnswer1.Text &= Answer1(i)
rdbAnswer2.Text &= Answer2(i)
rdbAnswer3.Text &= Answer4(i)
rdbAnswer4.Text &= Answer3(i)
Case Is = 3
rdbAnswer1.Text &= Answer1(i)
rdbAnswer2.Text &= Answer3(i)
rdbAnswer3.Text &= Answer2(i)
rdbAnswer4.Text &= Answer4(i)
Case Is = 4
rdbAnswer1.Text &= Answer1(i)
rdbAnswer2.Text &= Answer3(i)
rdbAnswer3.Text &= Answer4(i)
rdbAnswer4.Text &= Answer2(i)
Case Is = 5
rdbAnswer1.Text &= Answer1(i)
rdbAnswer2.Text &= Answer4(i)
rdbAnswer3.Text &= Answer2(i)
rdbAnswer4.Text &= Answer3(i)
Case Is = 6
rdbAnswer1.Text &= Answer1(i)
rdbAnswer2.Text &= Answer4(i)
rdbAnswer3.Text &= Answer3(i)
rdbAnswer4.Text &= Answer2(i)
Case Is = 7
rdbAnswer1.Text &= Answer2(i)
rdbAnswer2.Text &= Answer1(i)
rdbAnswer3.Text &= Answer3(i)
rdbAnswer4.Text &= Answer4(i)
Case Is = 8
rdbAnswer1.Text &= Answer2(i)
rdbAnswer2.Text &= Answer1(i)
rdbAnswer3.Text &= Answer3(i)
rdbAnswer4.Text &= Answer4(i)
Case Is = 9
rdbAnswer1.Text &= Answer2(i)
rdbAnswer2.Text &= Answer1(i)
rdbAnswer3.Text &= Answer3(i)
rdbAnswer4.Text &= Answer4(i)
Case Is = 10
rdbAnswer1.Text &= Answer2(i)
rdbAnswer2.Text &= Answer1(i)
rdbAnswer3.Text &= Answer3(i)
rdbAnswer4.Text &= Answer4(i)
Case Is = 11
rdbAnswer1.Text &= Answer2(i)
rdbAnswer2.Text &= Answer1(i)
rdbAnswer3.Text &= Answer4(i)
rdbAnswer4.Text &= Answer3(i)
Case Is = 12
rdbAnswer1.Text &= Answer2(i)
rdbAnswer2.Text &= Answer3(i)
rdbAnswer3.Text &= Answer1(i)
rdbAnswer4.Text &= Answer4(i)
Case Is = 13
rdbAnswer1.Text &= Answer2(i)
rdbAnswer2.Text &= Answer3(i)
rdbAnswer3.Text &= Answer4(i)
rdbAnswer4.Text &= Answer1(i)
Case Is = 14
rdbAnswer1.Text &= Answer2(i)
rdbAnswer2.Text &= Answer4(i)
rdbAnswer3.Text &= Answer1(i)
rdbAnswer4.Text &= Answer3(i)
Case Is = 15
rdbAnswer1.Text &= Answer2(i)
rdbAnswer2.Text &= Answer4(i)
rdbAnswer3.Text &= Answer3(i)
rdbAnswer4.Text &= Answer1(i)
Case Is = 16
rdbAnswer1.Text &= Answer3(i)
rdbAnswer2.Text &= Answer1(i)
rdbAnswer3.Text &= Answer2(i)
rdbAnswer4.Text &= Answer4(i)
Case Is = 17
rdbAnswer1.Text &= Answer3(i)
rdbAnswer2.Text &= Answer1(i)
rdbAnswer3.Text &= Answer4(i)
rdbAnswer4.Text &= Answer2(i)
Case Is = 18
rdbAnswer1.Text &= Answer3(i)
rdbAnswer2.Text &= Answer2(i)
rdbAnswer3.Text &= Answer1(i)
rdbAnswer4.Text &= Answer4(i)
Case Is = 19
rdbAnswer1.Text &= Answer3(i)
rdbAnswer2.Text &= Answer2(i)
rdbAnswer3.Text &= Answer4(i)
rdbAnswer4.Text &= Answer1(i)
Case Is = 20
rdbAnswer1.Text &= Answer3(i)
rdbAnswer2.Text &= Answer4(i)
rdbAnswer3.Text &= Answer1(i)
rdbAnswer4.Text &= Answer2(i)
Case Is = 21
rdbAnswer1.Text &= Answer3(i)
rdbAnswer2.Text &= Answer4(i)
rdbAnswer3.Text &= Answer2(i)
rdbAnswer4.Text &= Answer1(i)
Case Is = 22
rdbAnswer1.Text &= Answer4(i)
rdbAnswer2.Text &= Answer1(i)
rdbAnswer3.Text &= Answer2(i)
rdbAnswer4.Text &= Answer3(i)
Case Is = 23
rdbAnswer1.Text &= Answer4(i)
rdbAnswer2.Text &= Answer1(i)
rdbAnswer3.Text &= Answer3(i)
rdbAnswer4.Text &= Answer2(i)
Case Is = 24
rdbAnswer1.Text &= Answer4(i)
rdbAnswer2.Text &= Answer2(i)
rdbAnswer3.Text &= Answer1(i)
rdbAnswer4.Text &= Answer3(i)
Case Is = 25
rdbAnswer1.Text &= Answer4(i)
rdbAnswer2.Text &= Answer2(i)
rdbAnswer3.Text &= Answer3(i)
rdbAnswer4.Text &= Answer1(i)
Case Is = 26
rdbAnswer1.Text &= Answer4(i)
rdbAnswer2.Text &= Answer3(i)
rdbAnswer3.Text &= Answer1(i)
rdbAnswer4.Text &= Answer2(i)
Case Is = 27
rdbAnswer1.Text &= Answer4(i)
rdbAnswer2.Text &= Answer3(i)
rdbAnswer3.Text &= Answer2(i)
rdbAnswer4.Text &= Answer1(i)
End Select
If rdbAnswer1.Checked = True Then 'If the radial button is marked, perform the following. If not, continue down list until condition is met.
If RealAnswer(i) = rdbAnswer1.Text Then 'Check if RealAnswer(i) text is the same as Answer1(i)'s text. If not, continue down list until condition is met.
l += 1 'If the text matched, add 1 to variable l.
Else
l += 0 'If the text did not match, add nothing to variable l.
End If
ElseIf rdbAnswer2.Checked = True Then
If RealAnswer(i) = rdbAnswer2.Text Then 'Check if RealAnswer(i) text is the same as Answer1(i)'s text. If not, continue down list until condition is met.
l += 1 'If the text matched, add 1 to variable l.
Else
l += 0 'If the text did not match, add nothing to variable l.
End If
ElseIf rdbAnswer3.Checked = True Then
If RealAnswer(i) = rdbAnswer3.Text Then 'Check if RealAnswer(i) text is the same as Answer1(i)'s text. If not, continue down list until condition is met.
l += 1 'If the text matched, add 1 to variable l.
Else
l += 0 'If the text did not match, add nothing to variable l.
End If
ElseIf rdbAnswer4.Checked = True Then
If RealAnswer(i) = rdbAnswer4.Text Then 'Check if RealAnswer(i) text is the same as Answer1(i)'s text. If not, continue down list until condition is met.
l += 1 'If the text matched, add 1 to variable l.
Else
l += 0 'If the text did not match, add nothing to variable l.
End If
End If
i += 1 'Increment counter i.
Else
lblQuestion.Text = "Thank you for playing the game "
lblQuestion.Text &= usrName
lblQuestion.Text &= "." & vbCrLf
lblQuestion.Text &= "You answered "
lblQuestion.Text &= l
lblQuestion.Text &= "/20 questions correctly."
btnHint.Enabled = False
btnSubmit.Enabled = False
rdbAnswer1.Text = Nothing 'Clear text stored in the radial button rdbAnswer1
rdbAnswer2.Text = Nothing
rdbAnswer3.Text = Nothing
rdbAnswer4.Text = Nothing
grpAnswers.Enabled = False 'Disable Answer group box and all items contained.
End If 'Loop to Do statement until end of file is returned (value of -1).
End Sub

End Class
I am born to kill, judge and condemn


All this to run a simple quiz program on a windows machine that reads in a file and randomly places the answers for the problem among four radial buttons. Almost all of it works now... Just need to get the Restart button/drop down menu to work as I want it to, and insert a call command to pull up an email form in Outlook. Several months work, and several hundred lines to a thousand lines worth of coding. I hope this can go to show how much work people at places like gaia have to do just to the most mediocre of tasks within the flash games and the site itself.

I am born to win, slay and maim 'em





 
 
Manage Your Items
Other Stuff
Get GCash
Offers
Get Items
More Items
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff
Gaia's Games
Mini-Games
Play with GCash
Play with Platinum