473,513 Members | 2,560 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Array Concept Question


What's the difference between the following 3 declaration methods. I am
really confused out here.

Dim date1 as Date()
Dim date1() as Date
Dim date1(10) as Date

Your expert advise is needed.
Nov 21 '05 #1
7 1102
Nickson
Dim date1 as Date()
Dim date1() as Date They are both the same, an empty array with is declared to hold Date values
Dim date1(10) as Date

An array which holds 10 date values which have nothing as value.

I hope this helps?

Cor
Nov 21 '05 #2
On Tue, 12 Oct 2004 07:57:05 +0200, Cor Ligthert wrote:
Dim date1(10) as Date

An array which holds 10 date values which have nothing as value.


Oops Cor! I know that you know this, but that line creates an array of 11
date references (0-10). The dates have not been created yet.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 21 '05 #3
Chris,
Dim date1(10) as Date
An array which holds 10 date values which have nothing as value.
Oops Cor! I know that you know this, but that line creates an array of 11
date references (0-10). The dates have not been created yet.

Thanks about the 10, and than I answered before today why an array in VBNet
has one extra.

However the dates are created with nothing (base value) try this

Dim date1(10) as date
MessageBox.Show(date1(0).ToString)

It is a value you know.

Cor
Nov 21 '05 #4
"Chris Dunaway" <"dunawayc[[at]_lunchmeat_sbcglobal[dot]]net"> schrieb:
Dim date1(10) as Date

An array which holds 10 date values which have nothing as value.


Oops Cor! I know that you know this, but that line creates an
array of 11 date references (0-10). The dates have not been
created yet.


But there are actually no /references/ stored in the array... ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #5
Ok... I understand but when in my code I did this

Dim result() As String
result(0) = "test"

I get error but when I change the declaration to

Dim result(10) as String

the code works.

I impression on the first is that I have created a dynamic sized array that
automatically increase in size when more values are assigned? Am I wrong?
"Chris Dunaway" <"dunawayc[[at]_lunchmeat" wrote:
On Tue, 12 Oct 2004 07:57:05 +0200, Cor Ligthert wrote:
Dim date1(10) as Date

An array which holds 10 date values which have nothing as value.


Oops Cor! I know that you know this, but that line creates an array of 11
date references (0-10). The dates have not been created yet.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.

Nov 21 '05 #6
Nickson,

What you use is a fixed empty array what is not nice to use when it has to
increase.

When you want to add dynamicly to it you have to redimmension it using redim

However it is even stupid to show you because the arraylist is made for that
while this redimension of a fixed array is in my opinion a little bit for
backwards compatible use. The redim is not even in C#.

To make an arraylist is nothing more than
dim result as new arraylist
result.add("test")

And than "test" is
result(0) and because it is an object you have to tell when you use it
result(0).toString

I hope this helps?

Cor
"Nickson Koh" <Ni********@discussions.microsoft.com>
Ok... I understand but when in my code I did this

Dim result() As String
result(0) = "test"

I get error but when I change the declaration to

Dim result(10) as String

the code works.

I impression on the first is that I have created a dynamic sized array
that
automatically increase in size when more values are assigned? Am I wrong?
"Chris Dunaway" <"dunawayc[[at]_lunchmeat" wrote:
On Tue, 12 Oct 2004 07:57:05 +0200, Cor Ligthert wrote:
>
>> Dim date1(10) as Date
> An array which holds 10 date values which have nothing as value.
>


Oops Cor! I know that you know this, but that line creates an array of
11
date references (0-10). The dates have not been created yet.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.

Nov 21 '05 #7
Thx Cor.... The VB.NET array is now making more sense to me now : )
"Cor Ligthert" wrote:
Nickson,

What you use is a fixed empty array what is not nice to use when it has to
increase.

When you want to add dynamicly to it you have to redimmension it using redim

However it is even stupid to show you because the arraylist is made for that
while this redimension of a fixed array is in my opinion a little bit for
backwards compatible use. The redim is not even in C#.

To make an arraylist is nothing more than
dim result as new arraylist
result.add("test")

And than "test" is
result(0) and because it is an object you have to tell when you use it
result(0).toString

I hope this helps?

Cor
"Nickson Koh" <Ni********@discussions.microsoft.com>
Ok... I understand but when in my code I did this

Dim result() As String
result(0) = "test"

I get error but when I change the declaration to

Dim result(10) as String

the code works.

I impression on the first is that I have created a dynamic sized array
that
automatically increase in size when more values are assigned? Am I wrong?
"Chris Dunaway" <"dunawayc[[at]_lunchmeat" wrote:
On Tue, 12 Oct 2004 07:57:05 +0200, Cor Ligthert wrote:

>
>> Dim date1(10) as Date
> An array which holds 10 date values which have nothing as value.
>

Oops Cor! I know that you know this, but that line creates an array of
11
date references (0-10). The dates have not been created yet.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.


Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
6592
by: VK | last post by:
Whatever you wanted to know about it but always were affraid to ask. <http://www.geocities.com/schools_ring/ArrayAndHash.html>
29
5416
by: shmartonak | last post by:
For maximum portability what should the type of an array index be? Can any integer type be used safely? Or should I only use an unsigned type? Or what? If I'm using pointers to access array elements as *(mptr+k) where I've declared MYTYPE *mptr; what should be the type of 'k'? Should it be ptrdiff_t?
204
12895
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};
4
9669
by: mflll | last post by:
I am looking into the different techniques of handling arrays of edit boxes in Java Script. The first program below works fine. However, are there better ways of doing this, where the person writing the JavaScript doesn't have to pass the index in the "onChange" event name. I thought that one might be able to use "this.value" or...
104
16853
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from that array Could you show me a little example how to do this? Thanks.
30
3296
by: questions? | last post by:
say I have a structure which have an array inside. e.g. struct random_struct{ char name; int month; } if the array is not intialized by me, in a sense after I allocated a
45
4764
by: VK | last post by:
(see the post by ASM in the original thread; can be seen at <http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/3716384d8bfa1b0b> as an option) As that is not in relevance to "new Array() vs " question or to the array performance, I dared to move it to a new thread. Gecko takes undefined value strictly as per Book 4,...
272
13880
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two dimensional arrays from std::vectors ??? I want to use normal Array Syntax.
33
8143
by: Zytan | last post by:
I want to make a zero element array. I know that Nothing is not the same as a zero element array, since I can't get the length of, or iterate through, an array = Nothing. I could make a zero element array like this, but it seems like overkill: Dim emptyArray as Byte() = System.Text.Encoding.Default.GetBytes("") Is there a better way? ...
17
7212
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need to show the array data to the end user. Can I do that? How?
0
7178
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7397
Oralloy
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. ...
1
7128
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5103
isladogs
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...
0
4759
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...
0
3242
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1612
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
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.