473,791 Members | 3,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

General comment

In vbscript and vb6 when you created a array via a join that contained no
entries when you did a ubound against that array it returned -1, which of
course was very helpful for using it as the upper bound in a for loop. In
vb.net, in the same situation the ubound will return 0 and you get an array
with 1 null entry. I am missing something here or does this seem totally
incompatible?
Nov 21 '05 #1
4 1152
The documentation for both the String.Split and the
Microsoft.Visua lBasic.Split methods explicitly state:

<quote>
Return Value
An array consisting of a single element containing this instance,
if this instance contains none of the characters in separator.
</quote>

This IS different behaviour from VB6, and, in my opinion, finally corrected
a design fault. In VB6, take the string "x,y,z,". Apply the Split function
to it - Split("x,y,z,", ","), and the result is an array with 4 elements
(the empty string after the final comma is the 4th element). To be
consistent, I believe that Split("", ",") should have returned an array with
1 element. Because Split("", ",") actually returned an array with no
elements, then to be consistent I believe that Split(("x,y,z," , ",") should
have returned an array with 3 elements.

This inconsistent behaviour has been corrected in VB.NET.
"Bill" <Bi**@discussio ns.microsoft.co m> wrote in message
news:21******** *************** ***********@mic rosoft.com...
In vbscript and vb6 when you created a array via a join that contained no
entries when you did a ubound against that array it returned -1, which of
course was very helpful for using it as the upper bound in a for loop. In
vb.net, in the same situation the ubound will return 0 and you get an
array
with 1 null entry. I am missing something here or does this seem totally
incompatible?

Nov 21 '05 #2
Bill,

I agree with you that the array in VBNet has a very inconistent behaviour.

Confirm every other program language I know are "MyArray(10 )" ten strings,
while it is in VBNet eleven strings. In my opinion is this ver confusing. I
therefore understand that when you say.

string() = string.split("" )

Would expect at least 1 string because that would be than confusing because
string(0) = 1 string.

It would in my opinion be an improvement when this strange behaviour is once
banned from VBNet and that than 10 elements are really 10 elements and not
11.

Just my thought,

Cor
Nov 21 '05 #3
The original post had nothing to do with how a an array is declared. it was
about how the results of the Split function differed between VB6 and VB.NET.
That has been explained.

When arrays were introduced to BASIC, long before VB was a twinkle in Bill
Gate's eyes, the bounds were 1 based. This means that Dim x(10) As Integer
was the same as Dim x(1 To 10) As Integer. In those days, Dim x(10) As
Integer did, in fact, mean 'an array of 10 elements with subscripts 1 to 10
inclusive.

At some point in time, along came the Option Base statement where you could
declare that subscripts for your arrays were going to be 1 based or 0 based.
You could Use Option Base 0 or Option Base 1 as it took you fancy. If you
ommitted the Option base statement then it defaulted to Option Base 1.

If you used Option Base 0, Dim x(10) As Integer gave you an array of 11
elements subscripted by 0 to 10 inclusive and Dim x(0 to 9) As Integer gave
you an array of 10 elements subscripted by 0 to 9 inclusive.

The only, x(10), or last, x(0 to 10), part of the bounds clause has always,
in BASIC, determined the the upper bound of the array, NOT the number of
elements. It is coincidence that prior to Option Base the upper bound was
guaranteed to be the same as the number of elements.

As long as one 'thinks' BASIC when one is using BASIC then it is not
confusing at all. How one declares arrays in other languages is irrelevant.
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
Bill,

I agree with you that the array in VBNet has a very inconistent behaviour.

Confirm every other program language I know are "MyArray(10 )" ten strings,
while it is in VBNet eleven strings. In my opinion is this ver confusing.
I therefore understand that when you say.

string() = string.split("" )

Would expect at least 1 string because that would be than confusing
because string(0) = 1 string.

It would in my opinion be an improvement when this strange behaviour is
once banned from VBNet and that than 10 elements are really 10 elements
and not 11.

Just my thought,

Cor

Nov 21 '05 #4
Stephany,

Thanks, mostly I write this message in this newsgroup. This time I thought
that because of your previous message I don't do that. I always write that
the idea of using the first as starting indexer is more natural. As far as I
know has my language (and I assume a lot of others) not even a distinct
between "null" and "zero". For both "nul" is used. Although we have the
words "null" and "nothing", resp. "nul" and "niets".

And than I write that I consequently use the zero as starting indexer.

Cor
Nov 21 '05 #5

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

Similar topics

11
1970
by: Simon Shutter | last post by:
Forgive me if I am posting to wrong newsgroup and for a couple of loaded questions. First, from what I understand, one of the advantages of XHTML/CSS is the ability of screen readers/braille agents to provide an improved experience than HTML with table layout. Notwithstanding the leadership of Chevrolet, Amnesty International and others, at what point do you think XHTML/CSS will become the preferred approach? Will it be when the number...
3
2189
by: Aaron | last post by:
I'm a newbie so please bear with me... I'm looking to parse XML into a Collection so that I can pass that collection around to functions to extract data from it easily. I'm hoping there is code already to parse std XML files into a Collection? All I've found is code where the XML structure is already known... I need to code to work no matter what the structure... it would "figure out" what nodes are parents/children and such then place...
9
1389
by: -Michelle- | last post by:
This is a general question about back ends. Using in the scenario of a single user machine or *possibly* 2 networked machines. Therefore using SQL Server is not really an option. I need to write a database that keeps track of someone's sales (eg: jewellery shop). There would be tables with around 20000 records that would keep track of the stock items (wouldn't change much). The bulk of the work is based on sales made which of...
6
1573
by: Alex | last post by:
Hello I am intersting in developing and my background is VBA used in Excel and a brief intro to Java. I am interested in learning beyond VB and feel that C++ would be a very good language to get to know and give a lot of flexibility (if not tough to learn). I would like some advice on the merits of learning C++ versus C# or Visual Basic or Java for that matter.
3
2810
by: Clas | last post by:
Hi! I want to set up an exception handler in my asp.net page which handles all unhandled exception. When the exception is trapped I want to assign its message to a label. How can I do this? I have tryied to do like this: Protected Sub Page_Error(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Error Label.text = Server.GetLastError().Message()
4
1938
by: brooks | last post by:
I have an Access 97 app and the ADT and am considering selling it to the public. Is this viable? What issues might I have? I also have Access 2000 and could use that if it would be better. I don't have the "ADT" for 2000. Is it called ODE or ODT? Can you still buy that? Would there be any advantage in moving up to and distributing using
66
3743
by: KimmoA | last post by:
Hey! Some questions about C that have been bugging me for a while... 1) Is inline a valid C keyword or not? I was kind of surprised of not finding it in C, to be honest. My "The C Programming Language" book doesn't mention it. 2) I understand that C doesn't care about whitespace that much, but why did they make it impossible to use the minus ('-') char in variable names? I now have to incorrectly name my "hi-score" variable "hiscore"....
8
1823
by: boki_pfc | last post by:
Hi Everybody, I am looking for an advice on following: I have that "pleasure" of reading C++ codes that have been written by person(s) that have not attended the same C++ classes that I did or have not read the same C++ books that I have read. This kind of people has written some parts of the code that use notations that I am not familiar with (and that probably also includes also 50 % of other C ++ programmers). While everybody who...
2
1484
by: sono | last post by:
1. I am looking which HTML CODE is AS GENERAL AS POSSIBLE (i.e. independant of platform and browser). 2. To be more explicit : 2.a) I am writing HTML code which I would like to run on ALL possible platforms (PC, Mac, UNIX, …) and browsers (Safari, IE, Netscape, …) or at least as many as possible. 2.b) I use as well hyphens (in names with hyphens for hyphenation, etc.) as en-dashes - for a comment within a text like this one - and also...
0
9669
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9517
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10428
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10156
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9997
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9030
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6776
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();...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
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 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.