|
-
Jul 1st, 2007, 04:59 PM
#1
-
Mar 21st, 2008, 09:08 AM
#2
Junior Member
Re: [VB6] - Save/Load UDT Arrays Easily
I was going over this and it works great.
You said in the comments that it should be able to change the max amount of items (the header part) from 4 characters (9999) to whatever.
I tried changing it to 5 characters long, and I modified all the relevant code, however it didn't work anymore.
Also I noticed this:
Code:
Private Function BuildHeader(ByVal Length As Long) As String
BuildHeader = String$(Abs(4 - Len(CStr(UBound(udtTest())))), "0") & CStr(UBound(udtTest()))
End Function
Shouldn't this be
Code:
Private Function BuildHeader(ByVal Length As Long) As String
BuildHeader = String$(Abs(Length - Len(CStr(UBound(udtTest())))), "0") & CStr(UBound(udtTest()))
End Function
because otherwise you're not making any use of the Length parameter as far as I can see.
Any suggestions ?
I changed all 4's to a 5 and all 5's to a 6, and it saves properly, but doesn't load.
I even changed 4 to Length and it still wouldn't load after another save.
-
Mar 21st, 2008, 03:40 PM
#3
Re: [VB6] - Save/Load UDT Arrays Easily
Thanks for pointing that out about the BuildHeader function.
If you change the length of the header, say, to 5, then you will also need to modify the LoadUDT and SaveUDT routines, where it has something like (going from memory here):
Put #intFF, 5, udtArray()
to
Put #intFF, 6, udtArray()
Same for the Get #intFF
The 2nd argument specifies which byte the UDT data starts at, which is immediately after the header. So it should be +1 length of header.
If that doesn't work, you may need to decide on a header length and then delete the file and resave the UDT array.
-
Mar 21st, 2008, 05:54 PM
#4
Junior Member
Re: [VB6] - Save/Load UDT Arrays Easily
 Originally Posted by DigiRev
Thanks for pointing that out about the BuildHeader function.
No problem.
 Originally Posted by DigiRev
If you change the length of the header, say, to 5, then you will also need to modify the LoadUDT and SaveUDT routines, where it has something like (going from memory here):
(snip)
If that doesn't work, you may need to decide on a header length and then delete the file and resave the UDT array.
Tried that. Even deleted and resaved. Might not have done it in that order though :P can't think much lately.
will try again. 
EDIT: works. great job. this simplifies my saving by miles.
Last edited by mut80r; Mar 21st, 2008 at 06:08 PM.
Reason: Fixed It
-
Mar 21st, 2008, 06:38 PM
#5
Re: [VB6] - Save/Load UDT Arrays Easily
 Originally Posted by mut80r
No problem.
Tried that. Even deleted and resaved. Might not have done it in that order though :P can't think much lately.
will try again.
EDIT: works. great job. this simplifies my saving by miles.
You're welcome, glad it has helped someone. This is how I save a lot of data in my programs now also.
-
Oct 1st, 2013, 11:22 AM
#6
Lively Member
Re: [VB6] - Save/Load UDT Arrays Easily
...some posts never grow old!
Thanks for this post DigiRev. I was looking for a simple way to save/retrieve some data to text files in VBA, and this was just the ticket! I massaged your example project into a small class that suits my particular needs, and now I have a great reusable tool.
-Danny
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|