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

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 1136
The documentation for both the String.Split and the
Microsoft.VisualBasic.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**@discussions.microsoft.com> wrote in message
news:21**********************************@microsof t.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***************@tk2msftngp13.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
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...
3
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...
9
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...
6
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...
3
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...
4
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...
66
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...
8
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...
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.