|
-
Oct 31st, 2013, 02:57 AM
#1
Thread Starter
Addicted Member
Simple Quiz Application
Hello,
Been a while away from code, but trying to take a stab at writing a little quiz app but my code looks like I am trying too hard and runing slow. Can anyone give me an idea of what I'm doing right, if anything and what I might can change to get it working? I'm tring to pick a random line from a text file, break that into strings split by "," and pick the first resultant string and put it into label A for Answer A, B for Answer B.... and not use the same entry twice, as well as not put the entry into the same Ans twice. I will have picture boxes that I want to fill from a folder titled exactly what the correct answer is, and their is no text, the user guesses based on the image displayed in the text boxes, kinda the way Rosetta Stone works.
Code:
Imports System
Imports System.IO
Imports System.IO.File
Public Class Form1
'Program Variables
Dim width As String = My.Computer.Screen.WorkingArea.Width
Dim height As String = My.Computer.Screen.WorkingArea.Height
Dim h As String = AppDomain.CurrentDomain.BaseDirectory.ToString
Dim flist As String = File.ReadAllText(h & "flist.txt")
Dim priArray() As String = flist.Split(Environment.NewLine)
'Mushroom Variables
Dim chose As String
Dim pic As String = AppDomain.CurrentDomain.BaseDirectory & chose & "\"
'Functions
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.width = width - (width / 100 * 20)
Me.height = height - (height / 100 * 20)
Me.CenterToScreen()
End Sub
Public Sub FPickShroom()
Dim got(4) As String
Dim gotA(4) As String
Dim t As Integer = 5
Dim usedletters As String = "5"
Dim usedmush As String = "5"
Dim melike As String = "5"
Dim ListLines As String() = {"A", "B", "C", "D", "E"}
''Pick Mushrooms Randomly
Do Until usedletters.Contains(melike) = False
Dim Rand1 As New Random()
Dim Index1 As Integer = Rand1.Next(0, priArray.Length - 1)
Dim gethere() As String = priArray(Index1).Split(",")
melike = gethere(0)
Loop
usedmush &= melike
got(0) = melike
melike = "5"
Do Until usedletters.Contains(melike) = False
Dim Rand1 As New Random()
Dim Index1 As Integer = Rand1.Next(0, priArray.Length - 1)
Dim gethere() As String = priArray(Index1).Split(",")
melike = gethere(0)
Loop
usedmush &= melike
got(1) = melike
melike = "5"
Do Until usedletters.Contains(melike) = False
Dim Rand1 As New Random()
Dim Index1 As Integer = Rand1.Next(0, priArray.Length - 1)
Dim gethere() As String = priArray(Index1).Split(",")
melike = gethere(0)
Loop
usedmush &= melike
got(2) = melike
melike = "5"
Do Until usedletters.Contains(melike) = False
Dim Rand1 As New Random()
Dim Index1 As Integer = Rand1.Next(0, priArray.Length - 1)
Dim gethere() As String = priArray(Index1).Split(",")
melike = gethere(0)
Loop
usedmush &= melike
got(3) = melike
melike = "5"
Do Until usedletters.Contains(melike) = False
Dim Rand1 As New Random()
Dim Index1 As Integer = Rand1.Next(0, priArray.Length - 1)
Dim gethere() As String = priArray(Index1).Split(",")
melike = gethere(0)
Loop
usedmush &= melike
got(4) = melike
melike = "5"
''Pick Letters Randomly
Do Until usedmush.Contains(melike) = False
Dim Rand1 As New Random()
Dim Index1 As Integer = Rand1.Next(0, ListLines.Length - 1)
melike = ListLines(Index1)
Loop
usedletters &= melike
gotA(0) = melike
melike = "5"
Do Until usedmush.Contains(melike) = False
Dim Rand1 As New Random()
Dim Index1 As Integer = Rand1.Next(0, ListLines.Length - 1)
melike = ListLines(Index1)
Loop
usedletters &= melike
gotA(1) = melike
melike = "5"
Do Until usedmush.Contains(melike) = False
Dim Rand1 As New Random()
Dim Index1 As Integer = Rand1.Next(0, ListLines.Length - 1)
melike = ListLines(Index1)
Loop
usedletters &= melike
gotA(2) = melike
melike = "5"
Do Until usedmush.Contains(melike) = False
Dim Rand1 As New Random()
Dim Index1 As Integer = Rand1.Next(0, ListLines.Length - 1)
melike = ListLines(Index1)
Loop
usedletters &= melike
gotA(3) = melike
melike = "5"
Do Until usedmush.Contains(melike) = False
Dim Rand1 As New Random()
Dim Index1 As Integer = Rand1.Next(0, ListLines.Length - 1)
melike = ListLines(Index1)
Loop
usedletters &= melike
gotA(4) = melike
melike = "5"
If gotA(0) = "A" Then
AnsA.Text = got(0)
End If
If gotA(0) = "B" Then
AnsB.Text = got(0)
End If
If gotA(0) = "C" Then
AnsC.Text = got(0)
End If
If gotA(0) = "D" Then
AnsD.Text = got(0)
End If
If gotA(0) = "E" Then
AnsE.Text = got(0)
End If
If gotA(1) = "A" Then
AnsA.Text = got(1)
End If
If gotA(1) = "B" Then
AnsB.Text = got(1)
End If
If gotA(1) = "C" Then
AnsC.Text = got(1)
End If
If gotA(1) = "D" Then
AnsD.Text = got(1)
End If
If gotA(1) = "E" Then
AnsE.Text = got(1)
End If
If gotA(2) = "A" Then
AnsA.Text = got(2)
End If
If gotA(2) = "B" Then
AnsB.Text = got(2)
End If
If gotA(2) = "C" Then
AnsC.Text = got(2)
End If
If gotA(2) = "D" Then
AnsD.Text = got(2)
End If
If gotA(2) = "E" Then
AnsE.Text = got(2)
End If
If gotA(3) = "A" Then
AnsA.Text = got(3)
End If
If gotA(3) = "B" Then
AnsB.Text = got(3)
End If
If gotA(3) = "C" Then
AnsC.Text = got(3)
End If
If gotA(3) = "D" Then
AnsD.Text = got(3)
End If
If gotA(3) = "E" Then
AnsE.Text = got(3)
End If
If gotA(4) = "A" Then
AnsA.Text = got(4)
End If
If gotA(4) = "B" Then
AnsB.Text = got(4)
End If
If gotA(4) = "C" Then
AnsC.Text = got(4)
End If
If gotA(4) = "D" Then
AnsD.Text = got(4)
End If
If gotA(4) = "E" Then
AnsE.Text = got(4)
End If
'(Latin Name, Common Name)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
FPickShroom()
End Sub
End Class

Thank you for you help!
Chad
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|