So, I've been getting some help from the community on some issues (mainly G_Waddle, thanks again!). I'm a VB6 rookie, and it's been a while since I even did coding with that. So, basically here is my VB6 snippet. It's very straight forward and easy to code in VB6, but I am struggling in the conversion to .net. An answer is all I need, I'm one that takes an answer apart and figures out why it works. So, here's my code...anyone who can convert this over to VB.net is golden!! I really need some assistance with this if someone could take 5 minutes to do, I know it's got to be easy as can be! Thanks in advance guys!

csv/txt file data:
delta_x,delta_y,delta_z,h_x,h_y,h_z,lateral g's,yaw,acceleration,speed
0.1,1,10,0.1,1,10,5,15,25,35
0.2,2,20,0.2,2,20,10,20,30,40
0.3,3,30,0.3,3,30,15,25,35,45
0.4,4,40,0.4,4,40,20,30,40,50
0.5,5,50,0.5,5,50,25,35,45,55
0.6,6,60,0.6,6,60,30,40,50,60
0.7,7,70,0.7,7,70,35,45,55,65
0.8,8,80,0.8,8,80,40,50,60,70
0.9,9,90,0.9,9,90,45,55,65,75
1,10,100,1,10,100,50,60,70,80

Private Sub Form_Load()
Open App.Path & "\Test_data.csv" For Input As #1

Dim headings() As String
Line Input #1, variables
headings() = Split(variables, ",")

For i = 0 To UBound(headings)
Label1(i).Caption = headings(i)
Next

Do While Not EOF(1)
Line Input #1, variables
headings() = Split(variables, ",")

For i = 0 To UBound(headings)
List1(i).AddItem headings(i)
Next
Loop

Close #1
End Sub

Recommended Answers

All 2 Replies

Control arrays is almost non-existant in .NET, so therefore I replaced the label array and the List control with a DataGridView.

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
   Dim path As String = Application.StartupPath & "\Test_data.csv"
   Dim stream As System.IO.FileStream = Nothing
   Dim reader As System.IO.TextReader = Nothing
   Dim dt As New DataTable
   Dim headers() As String

   Try
      If System.IO.File.Exists(path) Then
         stream = New System.IO.FileStream(path, FileMode.Open, FileAccess.Read)
         reader = New System.IO.StreamReader(stream)

         While reader.Peek > 0
            line = reader.ReadLine()
            If lineNumber = 0 Then
               headers = line.Split(",")
               For i As Integer = 0 To headers.Length -1
                  dt.Columns.Add(headers(i), GetType(String))
               Next
            Else
               dt.Rows.Add(line.Split(","))
            End If
            lineNumber += 1
         End While
         reader.Close()
         stream.Close()

         DataGridView1.DataSource = dt
      End If
   Catch ex As Exception
      reader = Nothing
      stream = Nothing
   End Try
End Sub

Good luck!

That worked perfectly! You're the man Oxiegen!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.