| | |
Value of type 'String' cannot be converted to '1-dimensional array of String'?
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Mar 2008
Posts: 20
Reputation:
Solved Threads: 0
TEXT file csvSTOCKS.TXT contains the following:
Stock 1,200,300,200,200
Stock 2,200,300,200,200
Stock 3,200,300,200,200
Stock 4,200,300,200,200
Stock 5,200,300,200,200
I'm attempting to read each line in the text file and put it in the array of strings lines()
BUT, I get the following error when I try to assign lines = sr.ReadLine
ERROR:
If this cannot be done, is there a way to do that ?
tx
Stock 1,200,300,200,200
Stock 2,200,300,200,200
Stock 3,200,300,200,200
Stock 4,200,300,200,200
Stock 5,200,300,200,200
I'm attempting to read each line in the text file and put it in the array of strings lines()
vb Syntax (Toggle Plain Text)
Dim sr As StreamReader = New StreamReader("csvSTOCKS.TXT") Dim lines() As String Do While (sr.Peek <> -1) lines = sr.ReadLine Loop lstOutput.Items.Add(lines(0))
BUT, I get the following error when I try to assign lines = sr.ReadLine
ERROR:
VB.NET Syntax (Toggle Plain Text)
Error 1 Value of type 'String' cannot be converted to '1-dimensional array of String'.
If this cannot be done, is there a way to do that ?
tx
•
•
Join Date: Dec 2002
Posts: 461
Reputation:
Solved Threads: 56
Re: Value of type 'String' cannot be converted to '1-dimensional array of String'?
1
#2 Sep 19th, 2008
You have to redimension your lines array:
or use an array list:
VB.NET Syntax (Toggle Plain Text)
Dim sr As StreamReader = New StreamReader("csvSTOCKS.TXT") Dim lines() As String Dim index As Integer = 0 Do While (sr.Peek <> -1) ReDim Preserve lines(index) lines(index) = sr.ReadLine index += 1 Loop
or use an array list:
VB.NET Syntax (Toggle Plain Text)
Dim sr As StreamReader = New StreamReader("csvSTOCKS.TXT") Dim lines As ArrayList = Nothing Do While (sr.Peek <> -1) lines.Add(sr.ReadLine) Loop
Wayne
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
![]() |
Similar Threads
- Safe Array (C++)
- how to get thumbnail view using tree view (VB.NET)
- Tree view Problem...Plz help (VB.NET)
- Tree View Problem (VB.NET)
- How to change Yes/No (True/False) results from SQL query to checkboxes in DataGrid (VB.NET)
- Error:While creating DataSet... (ASP.NET)
- Info in Database converted to Chart (Visual Basic 4 / 5 / 6)
- Pointers (C++)
Other Threads in the VB.NET Forum
- Previous Thread: Pass an arrayList to a function
- Next Thread: ScreenHeiht
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account array basic beginner bing browser button buttons center check code crystalreport cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic dropdownlist excel fade file-dialog filter forms ftp generatetags google gridview hardcopy html images input insert intel internet mobile monitor net networking objects open output panel passingparameters pdf picturebox picturebox1 port position print printing problem save searchbox searchvb.net select serial settings shutdown soap sqlserver survey table tcp temperature text textbox timer timespan toolbox transparency trim update user vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode year





