What is the right way to declare an array

Dim lblname As Label() = New Label(get_num_of_children()) {}
Dim mealcheck As Integer() = New Integer(get_num_of_children()) {}

or

Dim lblname() As Label = New Label(get_num_of_children()) {}
Dim mealcheck() As Integer = New Integer(get_num_of_children()) {}

Thanks for your help

Recommended Answers

If your declaring an array with a initial number you should use:

Dim MealCheck(get_num_of_children) as Integer

If you want to set the array with initial values you should use:

dim MealCheck() as integer = {1,2,3}

If you want to create an empty array you …

Jump to Post

All 2 Replies

Member Avatar

If your declaring an array with a initial number you should use:

Dim MealCheck(get_num_of_children) as Integer

If you want to set the array with initial values you should use:

dim MealCheck() as integer = {1,2,3}

If you want to create an empty array you should use:

dim MealCheck() as integer = new integer(){}
commented: THanks for you Help +1

Thanks I guess I was using the syntax wrong but it still worked. I'm correcting my arrays now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.