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?
- Folder
- item1
- item2
- item3
- Folder2
- item1
- item2
- item3
Any ideas?
Why don't you put it in a Resouce file, essentially the same look and feel of a database, but without one.
A treeview?
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.
Another way should be to use ADO hierarchical recordset.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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
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.
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.
svafel, you abandoned the questions:
https://www.experts-exchange.com/jsp/qShow.jsp?ta=mssql&qid=20126403
https://www.experts-exchange.com/jsp/qShow.jsp?ta=mssql&qid=20134838
https://www.experts-exchange.com/jsp/qShow.jsp?ta=mssql&qid=20148082
https://www.experts-exchange.com/jsp/qShow.jsp?ta=as400&qid=20139402
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20136450
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20148746
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20152319
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20136451
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20142486
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20151411
please clear them up.
cjswimmer
https://www.experts-exchange.com/jsp/qShow.jsp?ta=mssql&qid=20126403
https://www.experts-exchange.com/jsp/qShow.jsp?ta=mssql&qid=20134838
https://www.experts-exchange.com/jsp/qShow.jsp?ta=mssql&qid=20148082
https://www.experts-exchange.com/jsp/qShow.jsp?ta=as400&qid=20139402
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20136450
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20148746
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20152319
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20136451
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20142486
https://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20151411
please clear them up.
cjswimmer
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
Ignorance is bliss
ASKER
I am happy to give up points...just get a little busy sometimes... :)
How is this question going?
Maybe you can use XML: http://www.xmlmag.com/upload/free/features/xml/2000/03sum00/rj0300/rj0300.asp
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.
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
Thank you,
Moondancer
Community Support Moderator @ Experts Exchange