 |
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: Data files within VB6
Depending on how much information there is....
You could store it in an array, or external file (database, text file, etc)
____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)
|
|
30-09-2005 at 06:45 PM |
|
|
stickleprojects Level: Moderator

 Registered: 09-09-2002 Posts: 891
|
Re: Data files within VB6
Hi,
Hope the following code will help. Paste it into a module and call the functions to read/save the array from/to file.
Usage:
dim ar(10) as integer
dim i as integer
for i=1 to 10
ar(i) = 19 + i
next i
SaveArrayToFile ar, "c:\mydata.txt"
dim new_ar() as integer
new_ar = ReadArrayFromFile ("c:\mydata.txt")
|
public sub SaveArrayToFile (arArray() as integer, strFileName as string)
dim fout as integer
' Get a free number for the file
fout = freefile
' Open the file for writing to
open strFileName for output as fout
dim i as integer
' as we are going to be reading the file in later, we output the size as the first line
print #fout, ubound(arArray)
' loop through the array, printing out the values
for i=lbound(arArray) to ubound(arArray)
print #fout,ararray(i)
next i
' close the file
close fout
end sub
public sub ReadArrayFromFile (strfileName as string) as integer()
dim fin as integer
dim arArray() as integer
dim strAline as string
dim i as integer
dim arraysize as integer
fin=freefile
open strfilename for input as fin
' the first line is the size of the array
' read a line
line input #fin,strAline
' set up the array
arraysize = val(strAline)
redim (ararray(arraysize))
' read the items from the file
for i=1 to arraysize
line input #fin, strAline
arArray(i) = val(strAline)
next i
' close the file
close fin
end sub
|
Hope this helps,
Kieron
____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)
|
|
01-10-2005 at 07:08 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1616
|
Re: Data files within VB6
if the data's not stored in a file, you have to manually set the values like you would any other variable (only taking into account the array element)
____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)
|
|
01-10-2005 at 10:43 PM |
|
|
|
|
 |
 |