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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

initialize array 1

Status
Not open for further replies.

briancostea

Programmer
Apr 21, 2005
82
US
is there a way initialize an array of integers to zero?
 
Code:
Dim NumArray(10) As Integer

erase NumArray

see MSDN for full info

If somethings hard to do, its not worth doing - Homer Simpson
 
Just define it:

Dim MyArr(...) As Integer

By default all its elements will have "0" value.



-bclt
 
if i use erase with an array of strings, will it set the elements to blanks? thanks.
 
erase will deallocate the memory. i just need to reset the array to blanks or zeros after i have used it. will the following work?

dim ar(10) as string
ar =
 
If you want to empty an array periodically use the Redim command without Preserve:

Dim ar() as String 'at Form Load makes ar dynamic
Redim ar(10) as String 'empties and sets indices from 0 to 10
.
.
.
Redim ar(10) as String 'Empties ar at a later point

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
Essex Steam UK for steam enthusiasts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top