By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,738 Members | 1,493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,738 IT Pros & Developers. It's quick & easy.

declaring array of type Dim q As Double(,)

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"mark" <ma**@discussions.microsoft.com> schrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2

P: n/a
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?

"Herfried K. Wagner [MVP]" wrote:
"mark" <ma**@discussions.microsoft.com> schrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3

P: n/a
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

"mark" <ma**@discussions.microsoft.com> wrote in message
news:2B**********************************@microsof t.com... 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?

"Herfried K. Wagner [MVP]" wrote:
"mark" <ma**@discussions.microsoft.com> schrieb:
> 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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.