0

Hi everyone,i'm currently making a random name picker .I got a csv excel file saved with 3 columns of data...one is the first name ,last name and tutor group.
I want to be able to search through the database and read just the first column of data and be able to randomise it so i can generate a random name.
I currently have this code but i know i got it completly wrong...

Dim Database As String()
Dim FileName As String = CurDir() & "NameDatabase.csv"
Dim RecordNumber As Short = 0

Private Sub Form1_Load()
        FileOpen(1, FileName, OpenMode.Input)
        For Row = 0 To EOF(1)
            For Column = 0 To 1
                Input(1, DataBase(Row, Column))
            Next Column
        Next Row
        FileClose(1)
        DisplayRecord()
End Sub
2
Contributors
2
Replies
20
Views
1 Year
Discussion Span
Last Post by Dec15
0

File.ReadAllLines(Filename).Length() will give you how many lines are in the file. Then generate a random number with that as the upper bound and read the first column of that row.

0

Ok thanks I will try that

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.