Link to home
Start Free TrialLog in
Avatar of svfafel
svfafel

asked on

Use an array to avoid using database

I am trying to avoid using a database but i need to store some information for data comparison.  I can hard code the information into an array or something.  THe data is fairly straight forward BUT it is somewhat relational.

- Folder
    - item1
    - item2
    - item3

- Folder2
    - item1
    - item2
    - item3


Any ideas?
Avatar of Dave_Greene
Dave_Greene

Why don't you put it in a Resouce file, essentially the same look and feel of a database, but without one.
Avatar of Éric Moreau
A treeview?
Avatar of svfafel

ASKER

sorry for the lack of info...this will be a formless app...running in the background...
Still, I suggest a resource file  :)
You can use a treeview that will be placed on a form that will never be displayed.

Another way should be to use ADO hierarchical recordset.
ASKER CERTIFIED SOLUTION
Avatar of PaulHews
PaulHews
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
yes, you can easily use an array as a heirarchical data store (this code off the top of my head):

Private Type tpData
    Data As Variant 'your data
    Parent As Long
End type

Dim atData() As tpData

Private Sub Form_Load()
    redim atData(whatever)

    atData(0).Data = whatever
    atData(0).Parent = -1 'root 'node'

    atData(1).Data = whatever
    atData(1).Parent = 0 'child of atData(0)

    atData(2).Data = whatever
    atData(2).Parent = 0

    atData(3).Data = whatever
    atData(3).Parent = 0

    atData(4).Data = whatever
    atData(4).Parent = -1 'root 'node'

    atData(5).Data = whatever
    atData(5).Parent = 4 'child of atData(4)

    atData(6).Data = whatever
    atData(6).Parent = 4

    atData(7).Data = whatever
    atData(7).Parent = 4

'you can even go as deep as you want:

    atData(8).Data = whatever
    atData(8).Parent = 7

    atData(9).Data = whatever
    atData(9).Parent = 8

End Sub

Okay - it's not terribly versatile, but you get the idea, and should work fine for reasonably static data.


If your data is static (i.e. unchanging), you can use a resource file as Dave Greene has suggested. You can think of a Resource File as a datafile embedded into your program.

If your data is dynamic, you can store the data into a text file which can be stored in the same directory as your executable. If the data is of a sensitive nature, you can encrypt it so that it is not readable from merely looking at the file. Your program can then load the data from the file at the beginning of your Sub Main(); it could be read into array(s) or collection(s), and depending upon the nature of your data you might find creating Classes advantageous.

-Dennis Borg
Hi,

You may find it more readable to use a type to store the information and to write it to a file. This type can contain arrays, strings, even other types if you want. You can write the entire type to a file using Put. Unfortunately, you may run into problems where you type needs to be part of a publicly creatable class, so that you can coerce it into a variant, which is a pain.

Zaphod.
cj, hahahaha :) he just doesn't want to lose any points :)
kind of strange because as soon as you offer up points for a question, you lose them unless you delete the question.  S/He doesn't have anything to lose by clearing up the questions...
yes, I know :)

Ignorance is bliss
Avatar of svfafel

ASKER

I am happy to give up points...just get a little busy sometimes... :)
How is this question going?
It's time to clean up this topic area and that means taking care of this question. Your options at this point are:
 
1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.
 
2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.
 
3.  Ask Community Support to help split points between participating experts.  Just comment here with details.
 
4.  Delete the question because it is of no value to you or to anyone else.  To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.
 
If you elect for option 2, 3 or 4, just post comment with details here and I'll take it from there.  We also request that you review any other open questions you might have and update/close them.  Display all your question history from your Member Profile to view details.
 
PLEASE DO NOT AWARD THE POINTS TO ME.
 
____________________________________________
 
 
 
Hi Experts:
 
In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest that I PAQ or delete the question.
 
Experts, please do not add further "answer" information to this question.  I will be back in about one week to finalize this question.
 
Thank you everyone.
 
Moondancer :)
Community Support Moderator @ Experts Exchange
 
P.S.  Engineering has been advised about the error in the comment date/time sort order.
Give the points to PaulHews
Force accepted by moderator.  In the event Asker returns with additional needs related to this question, please respond and continue the collaboration process.
Thank you,
Moondancer
Community Support Moderator @ Experts Exchange