Nemesis09
Active member
...help arraylist to array
Hi all,
This is my first post (probably of many) on this site, basically, I'm half ok at VB6 after playing with it as a hobby for a few years, and I figured it was about time I switched to .NET
Thats where all my problems began...
Ok, the one of most concern at the moment is this:
I'm trying to write an app that reads data from 2 comma separated text files, and puts these into a single 2 dimentional array basd on one of the culumns of data, such as.
Now, this seems like a simple enough task... but it just wont work. Heres my code as it stands (after more attempts than I can remember).
This seems to be getting close, but throws an error because apparently you cant convert a "String() to a String" ...um... why? whats the difference and whats the use of this "String()" type. I cant seem to do anything with it, not even set a label.text to it for debugging.
So I guess I'm asking, how do I get these arraylists into a type that I can actually use (ie. String)
Thanks for any and all help or suggestions (I'm still open to scrapping all this code and going for a different approach if there's a better way)
Hi all,
This is my first post (probably of many) on this site, basically, I'm half ok at VB6 after playing with it as a hobby for a few years, and I figured it was about time I switched to .NET
Thats where all my problems began...
Ok, the one of most concern at the moment is this:
I'm trying to write an app that reads data from 2 comma separated text files, and puts these into a single 2 dimentional array basd on one of the culumns of data, such as.
VB.NET:
Text File 1:
0001, data
0002, test
0003, other
0032, something
Text File 2:
0001, Fred
0002, John
0003, Sam
0032, Bert
Array:
0001, Fred, data
0002, John, test
0003, Sam, other
0032, Bert, something
VB.NET:
Dim employees(,)
Dim apppath AsString
Dim times(1, 3) AsString
Private Sub Form_load
apppath = Windows.Forms.Application.StartupPath
Dim arraylst AsNew ArrayList
Dim reader As Microsoft.VisualBasic.FileIO.TextFieldParser
reader = My.Computer.FileSystem.OpenTextFieldParser(apppath & "\employees.dat")
reader.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited
reader.SetDelimiters(",")
WhileNot reader.EndOfData
Try
arraylst.Add(reader.ReadFields)
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
MsgBox("Line " & ex.Message & "is not valid and will be skipped.")
EndTry
EndWhile
Dim employees As Array = arraylst.ToArray
Private Sub Button_1
Dim arraylst AsNew ArrayList
Dim reader As Microsoft.VisualBasic.FileIO.TextFieldParser
reader = My.Computer.FileSystem.OpenTextFieldParser(apppath & "\loggings.dat")
reader.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited
reader.SetDelimiters(",")
WhileNot reader.EndOfData
Try
arraylst.Add(reader.ReadFields)
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
MsgBox("Line " & ex.Message & "is not valid and will be skipped.")
EndTry
EndWhile
Dim times As Array = arraylst.ToArray
This seems to be getting close, but throws an error because apparently you cant convert a "String() to a String" ...um... why? whats the difference and whats the use of this "String()" type. I cant seem to do anything with it, not even set a label.text to it for debugging.
So I guess I'm asking, how do I get these arraylists into a type that I can actually use (ie. String)
Thanks for any and all help or suggestions (I'm still open to scrapping all this code and going for a different approach if there's a better way)
Last edited: