0

I have created a function that reads a Tab Delimited text file and create a data table as per it's header arrangement.

below is my code:

Private Function MakeDataTable(ByRef XSplitLine) As DataTable
    Dim AMZTable As New DataTable
    Dim i = 0
    For Each item In XSplitLine
        AMZTable.Columns.Add(XSplitLine(i).ToString)
        i += 1
    Next

    Return AMZTable
End Function

XSplitLine is an array that holds header Name(First Line in that text file) from a text file. As you can see I have not mentioned any data types while creating columns but still it executes without any error.

My question is what type of Value can be stored in these columns as I haven't mentioned it in the code?

MatSnow
  • 7,357
  • 3
  • 19
  • 31
J.Doe
  • 31
  • 1
  • 8
  • 1
    You should use [Option Strict On](https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/option-strict-statement) so that Visual Studio can point out some problems in the code for you. – Andrew Morton Oct 02 '18 at 13:32

1 Answers1

0

The datatype of the columns will be of type String.

As can be seen in https://referencesource.microsoft.com, the used overload of DataColumnCollection.Add calls the constructor of DataColumn which accepts a string as argument.
This in turn calls the constructor which accepts four arguments and sets the second argument (datatype) to typeof(string).

MatSnow
  • 7,357
  • 3
  • 19
  • 31