Re: Add/remove zero index of array



One other alternative, presuming that the goal of this effort is to keep prying eyes from seeing the values of the 0 member, is to just write the entire array to disk when overwrite the 0 record with some character. Then you can blast the mess back in later, and use the 0 member without any other footwork around the UTD/array format.

--


Randy
http://vbnet.mvps.org/


"Tim Rude" <timrude@xxxxxxxxxxxxxxxxxx> wrote in message news:u5BRUpmRIHA.4400@xxxxxxxxxxxxxxxxxxxxxxx
Yeah, if I wanted to rewrite a pile of code. ;p

Once the array is read, it is used throughout the program in a number of
ways, and the internally created record 0 becomes an important part of the
array data at that point. Some of the array data (including record 0) gets
displayed in a sorted listbox and the array index is stored in the ItemData
property. So eliminating record 0 from the array just complicates a bunch of
existing code that's currently working perfectly.

--
Tim Rude

timrude@xxxxxxxxxxxxxxxxxx
(remove NOSPAM. for correct email address)

"Randy Birch" <rgb_removethis@xxxxxxxx> wrote in message
news:eK85QbmRIHA.4272@xxxxxxxxxxxxxxxxxxxxxxx
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 ...
>>
>> "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
> of
>> > fixed length strings (i.e. String * 10, etc.). Each UDT record is >> > 322
>> 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
> won't
>> > 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
>>
>>
>
>




.



Relevant Pages

  • Re: Casting Problem returning an ArrayList
    ... the representation of the repeating data that has every appearance of ... there are ways to make your proxy programming model use array ... member of in Active Directory. ... >Dim arrGroupMemberships As New ArrayList ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: Penalty for instantiating an object tens of thousands of times?
    ... >> Dont forget you are storing references to these objects in the array. ... >>> You declare and use arrays of an object type just as you would declare ... >>> Instantiate each member of the array, or assign each member a reference ... >>> Dim q As Integer ...
    (microsoft.public.dotnet.languages.vb)
  • RE: Penalty for instantiating an object tens of thousands of times?
    ... > You declare and use arrays of an object type just as you would declare and ... > use an array of any data type. ... they contain one member more than the upper bound you declare. ... > Dim q As Integer ...
    (microsoft.public.dotnet.languages.vb)
  • arrays member as control variable?
    ... Is it a bug that you can't write ... dim nArrayas long ... It gives 'for control variable already in use', even though it is a different member of the array. ...
    (microsoft.public.vb.general.discussion)
  • Re: Detecting a running process.
    ... Private Declare Function EnumProcessModules Lib "psapi.dll" _ ... (ByVal dwProcessID As Long, _ ... Dim nProcesses As Long ... 'fill an array of longs with the ...
    (microsoft.public.vb.winapi)