Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Get array from a file in vb.net  (Read 3808 times)

0 Members and 1 Guest are viewing this topic.

almn

  • Guest
Get array from a file in vb.net
« on: November 26, 2006, 08:47:07 AM »
Hello,

I would like to know how to load the contenet of a file to an array in vb.net.
Example:

file.db:
hello,
hi
good
bad

Array:
index1 = hello,
index2 = hi
index3 = good
index4 = bad

Thanks

Al968



Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Get array from a file in vb.net
« Reply #1 on: November 26, 2006, 04:20:29 PM »
There is always the brute force method, read a record, redim the array, push the record into the array.

If this were a text file you can use the File.ReadAllLines(string) method, but since I notice your file name is a database, go with the brute force method and use ADO access methods for file.db

Happy Programming. 8-)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

Neil



    Expert
  • Fear me Track. Noone can escape my wrath.
  • Thanked: 3
    Re: Get array from a file in vb.net
    « Reply #2 on: November 27, 2006, 02:47:01 PM »
    You could include a number as the first entry of a file that tells you how many enteries there are. Or, if you pad all enteries out to a certain length, you can calculate from the file size, but that is disk space inefficient.