Re: Add/remove zero index of array
- From: "Randy Birch" <rgb_removethis@xxxxxxxx>
- Date: Mon, 24 Dec 2007 14:54:35 -0500
I would question the need for the 0 member at all, given - from your description - that you are only using the data this contains internally in the app and never saving to disk. Would not a separate dimmed variable for the data you put into the 0 member not work?
--
Randy
http://vbnet.mvps.org/
"Tim Rude" <timrude@xxxxxxxxxxxxxxxxxx> wrote in message news:uooT1NmRIHA.2376@xxxxxxxxxxxxxxxxxxxxxxx
Ralph,
Thanks for your input. I think I've actually got it sorted out now.
I'm using a trick suggested by RB Smissaert to adjust the LBound and UBound
of my array, and then shifting each record up or down. It works and it seems
very fast.
--
Tim Rude
timrude@xxxxxxxxxxxxxxxxxx
(remove NOSPAM. for correct email address)
"Ralph" <nt_consulting64@xxxxxxxxx> wrote in message
news:u4gbTCmRIHA.2268@xxxxxxxxxxxxxxxxxxxxxxx
Comments inline ...of
"Tim Rude" <timrude@xxxxxxxxxxxxxxxxxx> wrote in message
news:OXDRFYlRIHA.5288@xxxxxxxxxxxxxxxxxxxxxxx
> > <snipped>
>
> DB( ) is a single-dimension array of UDT records. The UDT consists only
> fixed length strings (i.e. String * 10, etc.). Each UDT record is 322won't
bytes
> long.
>
> '==========
> Dim FH as Integer
> Dim NumOfRecs as Long
> Dim DB() as MyUDT
>
> FH = FreeFile
> Open DataFile For Binary Shared As #FH
' if the dummy is the same size as MyUDT
Dim dummy As MyUDT
> NumOfRecs = LOF(FH) \ 322
NumOfRecs = NumOfRecs - 1
Get #FH, , dummy
> ReDim DB(1 To NumOfRecs - 1)
> Get #FH, , DB 'Read entire file into array
> Close #FH
>
> ReDim Preserve DB(0 to UBound(DB)) 'This is what I need to do but VB
> do it
> '==========
<snipped>
If it is a different size, say 300 bytes, do something like this...
[Warning Air Code!]
Dim dummy As String : dummy = String( 300, " ")
Get #FH, , dummy
Dim NumOfRecs As Long : NumOfRecs = LOF(FH) - 300
NumOfRecs = NumOfRecs / 322
...
-ralph
.
- Follow-Ups:
- Re: Add/remove zero index of array
- From: Tim Rude
- Re: Add/remove zero index of array
- References:
- Add/remove zero index of array
- From: Tim Rude
- Re: Add/remove zero index of array
- From: Ralph
- Re: Add/remove zero index of array
- From: Tim Rude
- Re: Add/remove zero index of array
- From: Ralph
- Re: Add/remove zero index of array
- From: Tim Rude
- Add/remove zero index of array
- Prev by Date: Re: Add/remove zero index of array
- Next by Date: Re: Add/remove zero index of array
- Previous by thread: Re: Add/remove zero index of array
- Next by thread: Re: Add/remove zero index of array
- Index(es):
Relevant Pages
|