Hi, I'm trying to make an app that is a multiple choice quiz. I have one question. I have a button click event that loads 4 lines of text to 4 separate textboxes, how can I click the same button again to add the next 4 lines of text in a text file to the textboxes? This is my code so far:
Public Class Form1
Dim lines() As String
Dim index As Integer = 0
Dim answers() As String
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
lines = IO.File.ReadAllLines("C:\Quiz\GenesisQuiz.txt")
answers = IO.File.ReadAllLines("C:\Quiz\GenesisAnswers.txt")
Private Sub Button40_Click(sender As Object, e As EventArgs) Handles Button40.Click
TextBox1.Text &= lines(index) & Environment.NewLine
index += 1
If index > lines.GetUpperBound(0) Then Button40.Enabled = False
End Sub
The above code loads my questions to a textbox 1 at a time as I hit the next button.
Private Sub Button40_MouseClick(sender As Object, e As MouseEventArgs) Handles Button40.MouseClick
If File.Exists("C:\Quiz\GenesisAnswers.txt") Then
Dim ioFile As New StreamReader("C:\Quiz\GenesisAnswers.txt")
TextBox2.Text = ioFile.ReadLine()
TextBox3.Text = ioFile.ReadLine()
TextBox4.Text = ioFile.ReadLine()
TextBox5.Text = ioFile.ReadLine()
End If
End Sub
This code loads my 4 answers to 4 separate textboxes with radio buttons at the right of the textbox to choose which answer to give. I need help on loading the next 4 answers in my text file to the 4 separate textboxes as the new question, question 2, is loaded. Thanks for your constructive criticism!