Group: Forum Members
Posts: 3,
Visits: 8
|
I have been really stumped by this one. Can anyone help me to read in a dat file and put the data (each one field) into textboxes. I will be comparing this file to a "master file" I will already have read into an array. Thank you for any help!
|
Group: Forum Members
Posts: 72,
Visits: 46
|
Have you successfully read the data into an array? If so, all you'd need to do is loop through the array to load the textboxes.
Let's see what code you already have.
|
Group: Forum Members
Posts: 3,
Visits: 8
|
Thank you....I got that going...now I'm just running into a problem when I try to compare the arrays. I don't get to the point of having the textboxes load because of an exception handling error. I don't understand what instance I'm missing. Here's the program: Public Class MainFormPrivate Answers() As CharPrivate Tested() As CharPrivate Index As Int16Private UIControl As ControlPrivate ThisTextBox As ControlPrivate IncorrectAnswers As Int16 = 0Private TextBox(19) As TextBox Private Sub MainForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadDim DataIn As StreamReaderDim IntegerCnt As Int16 = 1Dim Record As StringDim Field() As StringTextBox = {TextBox1, TextBox2, TextBox3, TextBox4, TextBox5, TextBox6, _ TextBox7, TextBox8, TextBox9, TextBox10, TextBox11, TextBox12, _ TextBox13, TextBox14, TextBox15, TextBox16, TextBox17, TextBox18, _ TextBox19, TextBox20} DataIn = New StreamReader(Application.StartupPath & "\Data\RMV Answers.dat")' Read in Answers fileDo While DataIn.Peek() <> -1Record = DataIn.ReadLine() Field = Record.Split() Answers(Index) = Field(0) Index += 1 'Increment the subscript valueLoopDataIn.Close() Index = 0 'Reinitialize Index'Read in tested fileDataIn = New StreamReader(Application.StartupPath & "\Data\RMV001.dat")Do While DataIn.Peek() <> -1Record = DataIn.ReadLine() Field = Record.Split() Tested(Index) = Record(0) Index += 1 'Increment the subscript valueLoopDataIn.Close() End SubPrivate Sub ClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.ClickDim UIControl As ControlFor Each UIControl In Me.ControlsIf TypeOf UIControl Is TextBox ThenThisTextBox = CType(UIControl, TextBox)ThisTextBox.Text = ""TextBox1.Focus() ResultsLabel.Text = ""End IfNextEnd SubPrivate Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.ClickDim Response As DialogResultResponse = MessageBox.Show("Do you really want to quit?", _"Confirmation required..", _MessageBoxButtons.YesNo, _MessageBoxIcon.Stop)If Response = Windows.Forms.DialogResult.Yes Then' When condition is TRUE, close the form.Me.Close()Else'When condition is FALSE, stay in the application.End IfEnd SubPrivate Sub ScoreButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ScoreButton.ClickConst MAX As Int16 = 19Dim Index As Int16For Index = 0 To MAXIf Answers(Index) = Tested(Index) ThenTextBox(Index).Text = Tested(Index).ToString() TextBox(Index).BackColor = Color.LawnGreenIncorrectAnswers += 1 ElseTextBox(Index).Text = Tested(Index).ToString() TextBox(Index).BackColor = Color.TomatoEnd IfIndex += 1 NextEnd SubPrivate Sub ResultsLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResultsLabel.ClickIf IncorrectAnswers > 5 ThenResultsLabel.Text = "Sorry. You did not pass the test. Try again in the future!"ElseResultsLabel.Text = "Congratulations! You passed!"End IfEnd SubEnd Class
|
Group: Forum Members
Posts: 3,
Visits: 8
|
Thank you...there were multiple issues...but taken care of and working great now!
|