I need to add to my project several two columns tables of data (from MS-Excel) I have saved in txt form, and I suppose I want to manage them in the form of lists or arrays.
Which is the easiest way to incorporate those files into the project?

Recommended Answers

All 6 Replies

I have no idea of what you really need.:)

Lets start with the language first, are you using vb6 or vba?

How do you want to manage these excel coloumns?
Lastly, incorporate them into the project, which project?

The language I'm using is Microsoft Visual Basic 2010.
You have an example of the data I want to manage in the attached file: two columns with numbers. These data don't change and that is the reason I want to include them in the VB form, because I have to make several searches into those data. I have to search within the fist column and give the result of the second column/same row.
The project is just a vb form which some simple calculations and a few searches within a couple of bidimensional arrays, lists or whatever.
Afterwards I have to draw a chart, but this will be after the calculations.
For looking into the arrays I suppose I have to use the SEEK command, but first I need the array as part of the project??

Thank you.

This will be a VB.NET question. I have asked the mods to move it from here (VB4/5/6) to .Net. I'm sure you will get a solution soon.:)

You can use List(of T) to hold data.

Public Class FileData
        Public Property Num1 As String
        Public Property Num2 As String
    End Class

    Class Test
      Sub ReadData()
        Dim lst As New List(Of FileData)
        Dim path As String ="c:\path\Dnormal1.txt"

        Dim lines() As String = System.IO.File.ReadAllLines(path)

        For Each Str As String In lines
            Dim ar() As String = Str.Split(New String() {vbTab}, StringSplitOptions.RemoveEmptyEntries)
            If ar.Length = 2 Then
                lst.Add(New FileData() With {.Num1 = ar(0), .Num2 = ar(1)})
            End If
        Next
    End Sub
   End Class

Edit:
Correct the path.

Thank you.
I have an error in the lack of declaration of the MapPath

Please don't use MapPath. Use absolute path.

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.