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 3 2185
"mark" <ma**@discussio ns.microsoft.co m> 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/>
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**@discussio ns.microsoft.co m> 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/>
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**@discussio ns.microsoft.co m> wrote in message
news:2B******** *************** ***********@mic rosoft.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**@discussio ns.microsoft.co m> 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/>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 22 of
section 6.2.5. If so, that seems to make it difficult to allocate such
structures, because sizeof() is not allowed on incomplete types
(paragraph 1 of section 6.5.3.4).
For instance, I've routinely done things like this:
struct foo {...
|
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 see how the return value comes to play here.
Ex
|
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;
...
}
|
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 = {0,1,2,4,9};
|
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 = {
{ 4.0, 2.0 },
{ 5.0, 8.0 },
{ 6.0, 6.0 },
| |
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 looked
sensible, but it didn't work right. Here is a simple example of what
I'm trying to accomplish:
// I have a hardware peripheral that I'm trying to access
// that has two ports. Each port has 10 sequential
// registers. Create a...
|
by: rayreeves |
last post by:
How do I declare an array of references to the elements of an array of
values?
Ray
|
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 the complete text of the error and be
specific about when and where it happens.
That said, in your code it's clear what's wrong:
|
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 = { { 3.14 }, { 42.6 } };
f((double *)array, sizeof array / sizeof **array);
return 0;
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |