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

All 2 Replies

Member Avatar for Unhnd_Exception

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.