Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to popluate an array with...

Status
Not open for further replies.

bjherron

IS-IT--Management
Jan 27, 2003
5
US
to make a long story short, I want to fill a 57377 byte array with the equivalent of continous 7F's in hex. Right now I have to have a seperate hex file filled with 7F's that I have to read in each time I run the program. I don't want to have to open this external each time to read it in the array. Do you know any way I can either attach the file to the program, or somehow setup a routine to fill the array with 7F's without calling an external file?

Thanks,
Brian
 
Why not use a simple loop

for lintLoop = lkbound(arrayX) to ubound(arrayX)
arrayX(lintloop) = "7F"
next lintloop

Someone else out there might know a faster method.
 
I've set this as in a public module:

Public myByte() As Byte
Public Sub fnFillByte(lngLength As Long, bytByte As Byte)
ReDim myByte(lngLength)
Dim lngCount As Long
For lngCount = 1 To lngLength
myByte(lngCount) = bytByte
Next lngCount
End Sub

You will need to convert your '7F' hex to decimal (127) or pass it as &H7F
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
You should be able to simply defing a string of the proper length and sharacter and reference it aas an array, or if you are REALLY picky, use LSet (or RSet) to place the string into the array. Of course you would want to do the latter in a small procedure so the extraneous (and somewhat long string) does not remain in scope (and therefore memory) throughout the existance/instantation of app.

On the other hand, what real use is such a beast? A constant is a constant is a constant ... is a constant, so the existance of all "1"'s is not really any different from the existance of all "0"'s, except for the 'negative' of the logic. The most general use of the 'structure' would be (in your case) to simply clear a bit (or byte) to indicate some item, so it is just as easy to simply invert the logic and set the bit (or byte) to indicate the same item.

MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Just to get things straight...
...do you want to fill the array with the string value "7F", or do you want to fill the array with chr(&7f), thus an array of string, of which all the strings are len=1.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top