Member Avatar

Hi everyone,i'm currently making a random name picker .I got a csv excel file saved with 3 columns of 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
End Sub

Recommended Answers

All 2 Replies

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.

Member Avatar

Ok thanks I will try that

Be a part of the DaniWeb community

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