grapes
i love grapes, and screwdrivers
Username:Yorkiebar Language:Visual Basic Watching:Family Guy website:sourcecodester
Imports System.IO
Dim questions As New List(Of String) Dim answers As New List(Of String) Dim hasQA As Boolean = False Dim curQuestion As Integer = -1 Dim ranQuestions As Integer = 0 Dim rand As Random = New Random() Dim rightQuestions As New List(Of String) Dim wrongQuestions As New List(Of String)
Dim fo As New OpenFileDialog fo.RestoreDirectory = True fo.ShowDialog() If (ranQuestions > 0) Then ranQuestions = 0 If (My.Computer.FileSystem.FileExists(fo.FileName)) Then Using sr As New streamreader(fo.FileName) While sr.peek <> -1 Dim line As String = sr.ReadLine() If (line.Contains(":")) Then If (Not hasQA) Then hasQA = True Dim splits As String() = line.Split(":") questions.Add(splits(0)) answers.Add(splits(1).ToLower()) End If End While End Using End If
curQuestion = rand.Next(questions.Count()) label4.Text = questions(curQuestion) ranQuestions += 1
Dim ans As String = TextBox1.Text.ToLower() If (ans = answers(curQuestion)) Then rightQuestions.add(curQuestion) Else : wrongQuestions.add(curQuestion) End If TextBox1.Text = "" If (Not ranQuestions >= NumericUpDown1.Value) Then Dim tempR As Integer = curQuestion Do Until Not tempR = curQuestion tempR = rand.Next(questions.Count()) Loop curQuestion = tempR Label4.Text = questions(curQuestion) ranQuestions += 1 Else MsgBox("Total Right: " & rightQuestions.Count() & vbNewLine & "Total Wrong: " & wrongQuestions.Count()) Dim wrongQs As String = "" For Each wrong As String In wrongQuestions If (wrongQs.Count() > 0) Then wrongQs &= ", " & questions(wrong) Else wrongQs &= questions(wrong) End If Next If (wrongQs.Count() > 0) Then MsgBox("Wrong Questions: " & vbNewLine & wrongQs) End If
Imports System.IO Public Class Form1 Dim questions As New List(Of String) Dim answers As New List(Of String) Dim hasQA As Boolean = False Dim curQuestion As Integer = -1 Dim ranQuestions As Integer = 0 Dim rand As Random = New Random() Dim rightQuestions As New List(Of String) Dim wrongQuestions As New List(Of String) Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim fo As New OpenFileDialog fo.RestoreDirectory = True fo.ShowDialog() If (ranQuestions > 0) Then ranQuestions = 0 If (My.Computer.FileSystem.FileExists(fo.FileName)) Then Using sr As New streamreader(fo.FileName) While sr.peek <> -1 Dim line As String = sr.ReadLine() If (line.Contains(":")) Then If (Not hasQA) Then hasQA = True Dim splits As String() = line.Split(":") questions.Add(splits(0)) answers.Add(splits(1).ToLower()) End If End While End Using End If End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click curQuestion = rand.Next(questions.Count()) label4.Text = questions(curQuestion) ranQuestions += 1 End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click Dim ans As String = TextBox1.Text.ToLower() If (ans = answers(curQuestion)) Then rightQuestions.add(curQuestion) Else : wrongQuestions.add(curQuestion) End If TextBox1.Text = "" If (Not ranQuestions >= NumericUpDown1.Value) Then Dim tempR As Integer = curQuestion Do Until Not tempR = curQuestion tempR = rand.Next(questions.Count()) Loop curQuestion = tempR Label4.Text = questions(curQuestion) ranQuestions += 1 Else MsgBox("Total Right: " & rightQuestions.Count() & vbNewLine & "Total Wrong: " & wrongQuestions.Count()) Dim wrongQs As String = "" For Each wrong As String In wrongQuestions If (wrongQs.Count() > 0) Then wrongQs &= ", " & questions(wrong) Else wrongQs &= questions(wrong) End If Next If (wrongQs.Count() > 0) Then MsgBox("Wrong Questions: " & vbNewLine & wrongQs) End If End Sub End Class
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.