Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Dim streamReader As IO.StreamReader = New IO.StreamReader("D:\PORTFOLIO1.txt")

While streamReader.Peek() <> -1
    Dim ROWVALUE As String
    Dim CELLVALUE(7) As String
    'Dim MYROWCOUNT As String = DataGridView1.Rows.Count - 1
    'Dim MYCOLUMCOUNT As String = DataGridView1.ColumnCount - 1


    ROWVALUE = streamReader.ReadLine()
    CELLVALUE(7) = ROWVALUE.Split(",") 'check what is ur separator
    DataGridView1.Rows.Add(cellValue)
End While

The file "d:portfolio1.txt" contains
,,N,Copper,20-05-2015,N,copper

i am facing errors when running my the above code,
i request you to solve the problem in the above code
Posted
Updated 19-May-15 23:51pm
v2
Comments
OriginalGriff 20-May-15 4:15am    
What errors?
OriginalGriff 20-May-15 4:32am    
Just to expand on my previous comment:
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
So we have no idea what errors you are getting, and we don;t have access to your data, so we can't run it and find out.
Use the "Improve question" widget to edit your question and provide better information.

1 solution

The problem is about how you handle arrays...
CELLVALUE is a string array of 7 elements...
String.Split() returns an array...
But! You try to push that array from Split() method into the 7th element of the CELLVALUE array!!!
You should do something like this:
VB
Dim CELLVALUE As String()

CELLVALUE = ROWVALUE.Split(",") 
 
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