473,387 Members | 1,549 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,387 software developers and data experts.

Defining the range of an array

If we declar a varible as:

Dim series(10) as Double

then series can contain 11 items in maximum ( 0 - 11 ).
How do you declar this varible, making the first item as

series(1)

instead of

series(0)

? Thanks.

--
Xero

http://www.chezjeff.net
My personal web portal
Nov 21 '05 #1
6 1194
Hi.

Sorry you cant. The first element in an array is zero in vb.net

Ken
-----------------
"Xero" <jeff_@_chezjeff_._net(remove_underscores_and_this )> wrote in message
news:B2**********************************@microsof t.com...
If we declar a varible as:

Dim series(10) as Double

then series can contain 11 items in maximum ( 0 - 11 ).
How do you declar this varible, making the first item as

series(1)

instead of

series(0)

? Thanks.

--
Xero

http://www.chezjeff.net
My personal web portal
Nov 21 '05 #2
Jeff,

A little addition to Ken

then series can contain 11 items in maximum ( 0 - 11 ).

(0 - 10)

Than you understand probably why

Cor
Nov 21 '05 #3
You are saying that the first item in the array is series(0)
and the tenth item (i.e. the last item) in the array is series(10)

This statement Dim series(10) as Double actually can
accommodate 10 items only.

Am I correct?

Xero
"Cor Ligthert" wrote:
Jeff,

A little addition to Ken

then series can contain 11 items in maximum ( 0 - 11 ).

(0 - 10)

Than you understand probably why

Cor

Nov 21 '05 #4
Jeff,

It is a strange way of keeping compatibility that is taken, and maybe it
could have been avoided, however all methods or whatever in the VB namespace
is using for indexing the start index First where First is 1.

The rest of dotnet methods or whatever are using for First the zero.

Although I am used to the zero start indexer, is in my opinion the way VB
does it better. However, you cannot turn history back so most of us with not
only VB background are using the zero indexer.

Dim i(10) as integer are 11 integers in an array.
Usable from 0 to 10 what are eleven or 1 to 10 what are ten integers

And therefore I use
dim i(9) as integer when I want 10 integer is an array.

It looks strange, however I hope this helps anyway something.

Cor

"Xero" <jeff_@_chezjeff_._net(remove_underscores_and_this )>
You are saying that the first item in the array is series(0)
and the tenth item (i.e. the last item) in the array is
series(10)

This statement Dim series(10) as Double actually can
accommodate 10 items only.

Am I correct?

Xero
"Cor Ligthert" wrote:
Jeff,

A little addition to Ken
>
> then series can contain 11 items in maximum ( 0 - 11 ).

(0 - 10)

Than you understand probably why

Cor

Nov 21 '05 #5
Xero,

No, when dimensioning an array, you specifiy the upper bound of the array,
with the lower bound always being zero.

So,

Dim series (10) As Double

will produce an array with 11 elements, numbered 0 through 10.

Kerry Moorman
"Xero" wrote:
You are saying that the first item in the array is series(0)
and the tenth item (i.e. the last item) in the array is series(10)

This statement Dim series(10) as Double actually can
accommodate 10 items only.

Am I correct?

Xero
"Cor Ligthert" wrote:
Jeff,

A little addition to Ken

then series can contain 11 items in maximum ( 0 - 11 ).

(0 - 10)

Than you understand probably why

Cor

Nov 21 '05 #6
I see ...
Thanks, guys!

Xero
"Cor Ligthert" wrote:
Jeff,

It is a strange way of keeping compatibility that is taken, and maybe it
could have been avoided, however all methods or whatever in the VB namespace
is using for indexing the start index First where First is 1.

The rest of dotnet methods or whatever are using for First the zero.

Although I am used to the zero start indexer, is in my opinion the way VB
does it better. However, you cannot turn history back so most of us with not
only VB background are using the zero indexer.

Dim i(10) as integer are 11 integers in an array.
Usable from 0 to 10 what are eleven or 1 to 10 what are ten integers

And therefore I use
dim i(9) as integer when I want 10 integer is an array.

It looks strange, however I hope this helps anyway something.

Cor

"Xero" <jeff_@_chezjeff_._net(remove_underscores_and_this )>
You are saying that the first item in the array is series(0)
and the tenth item (i.e. the last item) in the array is
series(10)

This statement Dim series(10) as Double actually can
accommodate 10 items only.

Am I correct?

Xero
"Cor Ligthert" wrote:
Jeff,

A little addition to Ken

>
> then series can contain 11 items in maximum ( 0 - 11 ).
(0 - 10)

Than you understand probably why

Cor


Nov 21 '05 #7

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

Similar topics

8
by: Pjotr Wedersteers | last post by:
Hello, I tried to create an array with 1000 cells, keys 0 thru 999 using $myarr = array (1000); But this leads to an array of 1 cell with value 1000; Now I have a workable solution for...
5
by: Xah Lee | last post by:
© # the following is a example of defining © # a function in Python. © © def fib(n): © """This prints n terms of a sequence © where each term is the sum of previous two, © starting...
2
by: George | last post by:
Is there a fast way to transfer an Excel range to an array? Example: Excel range is E2:E300 Dim person() as string Thanks, George
3
by: George | last post by:
Sub ExcelToListBox() Dim xRange As Object Dim ary Dim xValue As String xRange = oXL.Range("A1:A9") 'has letters A-H ary = xRange.value xValue = ary(3, 1) 'xValue = C...
12
by: Adam Hartshorne | last post by:
Hi All, I was wondering if somebody could post a few lines of code which would produce random colors, which will be used in defining different regions on a mesh. So in addition to having n...
10
by: nambissan.nisha | last post by:
I am facing this problem.... I have to define a structure at runtime as the user specifies... The user will tell the number of fields,the actual fields...(maybe basic or array types or...
2
by: Helpful person | last post by:
I wish to access several pictures on my page by defining them as an array. This way I can either loop through them or access them by array index. I am a beginner at Javascript so please keep...
11
by: Tempo | last post by:
Hello. I am getting the error that is displayed below, and I know exactly why it occurs. I posted some of my program's code below, and if you look at it you will see that the error terminates the...
85
by: Russ | last post by:
Every Python programmer gets this message occasionally: IndexError: list index out of range The message tells you where the error occurred, but it doesn't tell you what the range and the...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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...
0
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,...
0
jinu1996
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...

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.