473,386 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

declaring array of type Dim q As Double(,)

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
3 2167
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Eric Smith | last post by:
Is a structure containing an incomplete array as its last element (per paragraph 2 of section 6.7.2.1 of ISO/IEC 9899:1999 (E)) itself an incomplete type? That appears to be indicated by paragraph...
16
by: G Patel | last post by:
Hi, If I want to call functions that don't return int without declaring them, will there be any harm? I only want to assign the function(return value) to the type that it returns, so I don't...
10
by: nospam | last post by:
Hello! I can pass a "pointer to a double" to a function that accepts double*, like this: int func(double* var) { *var=1.0; ... }
204
by: Alexei A. Frounze | last post by:
Hi all, I have a question regarding the gcc behavior (gcc version 3.3.4). On the following test program it emits a warning: #include <stdio.h> int aInt2 = {0,1,2,4,9,16}; int aInt3 =...
18
by: bsder | last post by:
Hi, Can anyone please tell me how to calculate the size of the following 4-dimensional array, and now to use qsort for sorting on this array? double sp = { 4.0, 5.0, 6.0 }; double spa = { {...
12
by: gcary | last post by:
I am having trouble figuring out how to declare a pointer to an array of structures and initializing the pointer with a value. I've looked at older posts in this group, and tried a solution that...
11
by: rayreeves | last post by:
How do I declare an array of references to the elements of an array of values? Ray
4
by: Peter Duniho | last post by:
On Thu, 14 Aug 2008 18:56:00 -0700, Phill <Phill@discussions.microsoft.comwrote: For future reference, if you are asking for help with an error (compile or execution), you really should post...
152
by: vippstar | last post by:
The subject might be misleading. Regardless, is this code valid: #include <stdio.h> void f(double *p, size_t size) { while(size--) printf("%f\n", *p++); } int main(void) { double array = { {...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.