|
-
Sep 16th, 2009, 05:45 PM
#1
Thread Starter
New Member
Help Please
Sorry, I know that is really basic, but I really need help with this. I'm trying to write a program and I'm having trouble in the section of code where I load the file. The file contains, on the first line, a number, telling half as many other lines there are. The other lines are pairs of questions and answers. Below, I'm trying to take the first line and save it to an integer called number. Then, I use that number to start a loop and put the questions and answers into an array called array. I don't seem to be reading anything. Do you think you can help me, please?
Code:
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
state = 3
TextBox1.Visible = True
Button2.Visible = True
Dim result As DialogResult
OpenFileDialog1.ShowDialog()
Dim filename As String = OpenFileDialog1.FileName
If result = DialogResult.OK Then
Dim read As New System.IO.StreamReader(filename)
number = Val(read.ReadLine - vbNewLine)
Dim counter As Integer
For counter = 1 To number
array(counter, 1) = read.ReadLine
array(counter, 2) = read.ReadLine
counter = counter + 1
Next
read.Close()
End If
For counter = 1 To number
todo(counter) = counter
Next
tempnum = 1
wrongcount = 0
TextBox1.Text = array(1, 1)
End Sub
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
|