English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I want to add values to a one dimensional array

Is this correct

dim ratings () as string
ratings(1)="3 hp"
ratings(2)="5hp"

I receive"invalid outside procedure"

thank you

2007-07-15 02:23:18 · 4 answers · asked by toms r 1 in Computers & Internet Programming & Design

I am using the visual Basic editor in
Microsoft Excel
The array is to enter different values into
certain cells,if the cells happen to be empty

2007-07-17 15:29:55 · update #1

4 answers

Tom read this

http://books.google.co.uk/books?id=WIYUyveM_hIC&dq=How+to+Visual+Basic+and+arrays&pg=RA1-PA7-IA1&ots=XhiLt8fXft&sig=UGegZfqH4GoibgGUF0xLoeYu1mc&prev=http://www.google.co.uk/search%3Fhl%3Den%26q%3DHow%2Bto%2BVisual%2BBasic%2Band%2Barrays%26meta%3D&sa=X&oi=print&ct=result&cd=2

http://www.google.co.uk/search?hl=en&q=sample+Visual+Basic+and+arrays&meta=

2007-07-15 02:31:16 · answer #1 · answered by Joe_Young 6 · 0 0

You have declared a dynamic array. It must be sized before you can populate it. Also, remeber that arrays are zero-based unless you put "Option Base 1" at the top of the module.

If you know that the array size will not change, declare it as such: "dim ratings(2) as string" creates an 3-member array (0-2).

If the array must be dynamic:
dim ratings() as string
stuff happens, you determine the array size to be "x"
redim ratings(x)

As to what a previous answerer said, array declarations and usage can appear in anywhere is a code project. It is not limited to event procs.

2007-07-15 04:46:46 · answer #2 · answered by HeadScratcher98 3 · 0 0

Const _MAX=six hundred Const _MIN=4 hundred For intIndex=0 To ninety 9 if intNumber(intIndex) <= _MIN Then intNumber(intIndex) = _MIN end If next intIndex lsbAnswer.products.upload(intIndex) you may desire to substitute the listbox project from lsbAnswer.products.upload(intSmallest) to lsbAnswer.products.upload(intIndex). you're basically assigning the fee of the factor(new launch declared via intSmallest, which grew to become into probably 4 hundred or 0) to the field.

2016-11-09 09:16:25 · answer #3 · answered by jannelle 4 · 0 0

i think Ur array declaration is correct but initialization is incorrect....vb is an event driven pgm language..so initialize it inside an event

2007-07-15 03:55:56 · answer #4 · answered by rajumon 2 · 0 0

fedest.com, questions and answers