declaring array of type Dim q As Double(,)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I declare an array as double(,) then try to use it I get an error:
"Object reference not set to an instance of an object."
I have found that I can redim the array and all is well. Is my approach
proper here or is the a better way for setting the instance of this specific
format for an array.
 
mark said:
When I declare an array as double(,) then try to use it I get an error:
"Object reference not set to an instance of an object."
I have found that I can redim the array and all is well. Is my approach
proper here or is the a better way for setting the instance of this
specific
format for an array.

\\\
Dim adbl(9, 9) As Double
///

.... will create a 10 x 10 double array.
 
Yes. However, in reference to our earlier discussion I want to be able to
avoid the latebinding error I get when I pass an array declared in this
fashion. I am guessing that I should continue to use the a(9,9) as double
format for declaring arrays and I should use the "a as double(,)" format for
typing the procedure arguments. Do I have this right?
 
Mark,
I am guessing that I should continue to use the a(9,9) as double
format for declaring arrays
Yes you either need to give the size of the array or initialize it when you
declare the array itself. Going back to your original question, you
initialized the array with "{{1, 2}, {3, 4}, {5, 6}}" which will implicitly
set the size.

Dim a(,) As Double = {{1, 2}, {3, 4}, {5, 6}}

Using ReDim will also initialize the array.

ReDim a(9,9)
I should use the "a as double(,)" format for
typing the procedure arguments.

Yes you need to use "a as double(,)" for parameters/arguments so the
compiler knows the specific type of the array, size is not important here,
as the array itself knows how big it is...

Private Sub T1(ByVal a As Double(,))
Dim i, j As Integer
For i = 0 To 2
For j = 0 To 2
a(i, j) = 2 * a(i, j) Underlined as latebinding error
Next
Next
End Sub

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top