简体   繁体   English

数组的Visual Basic第一个元素

[英]Visual basic first element of array

I'm just starting with visual basic. 我只是从视觉基础开始。

The first element in an array 数组中的第一个元素

ie dim y(9) as Integer dim y(9) as Integer

Will that have elements 0-8 or 1-9 in? 会包含元素0-81-9吗?

ie if I did 即如果我做到了

y(1) = 84

does that make the first or second element in the array equal to 84? 这会使数组中的第一个或第二个元素等于84吗?

I've looked at a few online sources and I'm a bit confuzzled. 我看了一些在线资源,我有些困惑。

Thanks 谢谢

The first position for arrays in VB.NET is zero; VB.NET中数组的第一个位置为零; same rules apply to any in-built collection/function requiring indexing and to other .NET languages, like C#. 相同的规则适用于任何需要建立索引的内置集合/函数以及其他.NET语言(例如C#)。 On the other hand, "old" VB (VB6 and older or VBA) has zero as first index for arrays and one for in-built functions (this is somehow confusing for people coming from VB to VB.NET). 另一方面,“旧的” VB(VB6和更旧的VB)具有零作为数组的第一索引,而对于内置函数则具有一个(对于从VB到VB.NET的人们来说,这有点令人困惑)。 What is common to all the VB versions (.NET and older ones) and different to other languages like C#, is that the number used when instantiating the array (9 in y(9) ) does not indicate its size but its last index (the size of y(9) is 10). 所有VB版本(.NET和更早版本)的共同点是与C#等其他语言的不同之处在于,实例化数组时使用的数字( y(9) )中的y(9) )并不指示其大小,而是指示其最后一个索引( y(9)的大小是10)。

In summary, your array includes 10 positions: from 0 to 9. 总而言之,您的数组包含10个位置:从0到9。

The elements in the array start from 0 in VB.NET 数组中的元素在VB.NET中从0开始

A sample example from MSDN : 来自MSDN的示例示例:

在此处输入图片说明

You may also find this interesting to read:- Why numbering should start at zero 您可能还会发现以下有趣的内容:- 为什么编号应从零开始

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM