Click here to Skip to main content
15,911,531 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
So i need to import data from a textfile to a data grid view using a read and write array which i use to save the data to the file. Here is the read procedure :
VB
Sub readrecord()
      'Declare Variables
      Dim intcounter As Integer
      'Reads how many Records are in file
      intNumberofRecords = filereader.ReadLine

      ReDim QuestionArray(intNumberofRecords)

      intcounter = 0
      Do Until filereader.EndOfStream = True

          intcounter = intcounter + 1
          'reads each line for each variable
          QuestionArray(intcounter).strQuestionID = filereader.ReadLine
          QuestionArray(intcounter).strQuestion = filereader.ReadLine
          QuestionArray(intcounter).strAnswer1 = filereader.ReadLine
          QuestionArray(intcounter).strAnswer2 = filereader.ReadLine
          QuestionArray(intcounter).strAnswer3 = filereader.ReadLine
          QuestionArray(intcounter).strAnswer4 = filereader.ReadLine



      Loop

  End Sub


the data in the text file is stored on separate lines. I would really appreciate if someone could point me in the right direction for this

thanks,
Daniel
Posted

1 solution

Add this:
VB
    QuestionArray(intcounter).strAnswer4 = filereader.ReadLine
    myDataGridView.Rows.Add(QuestionArray(intcounter))
Loop
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900