473,699 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UBound behaviour

I have the following code below.

The thing is, even if txtCCEmailAddre ss.Text is empty (no text), CCRecipeant
will return a Ubound() higher than 0 and still go in the loop.

If there's nothing to split how can CCRecipeant be a positive UBound value?
'Get the number of specified CC recipeants

CCRecipeant = txtCCEmailAddre ss.Text.Split(" ;")

'Now we need to add each one

For intCounter = 0 To CCRecipeant.Get UpperBound(0)

If CCRecipeant.Get UpperBound(0) >= 0 Then

..........some code here

End If

Next

Thanks,

Adam
May 8 '06 #1
2 1660
Hi,

From .NET documentation.


Function Split(
ByVal Expression As String,
Optional ByVal Delimiter As String = " ",
Optional ByVal Limit As Integer = -1,
Optional ByVal Compare As CompareMethod = CompareMethod.B inary
) As String()
If Expression is a zero-length string (""), the Split function returns
an array of length one, containing an empty string.

Can you test txtCCEmailAddre ss.Text for length first?

Fred

May 8 '06 #2
Adam Honek wrote:
I have the following code below.

The thing is, even if txtCCEmailAddre ss.Text is empty (no text), CCRecipeant
will return a Ubound() higher than 0 and still go in the loop.
No, it wont. If the string is empty, the array will contain one item, so
UBound will return the value zero. That will make the loop iterate once.
If there's nothing to split how can CCRecipeant be a positive UBound value?
'Get the number of specified CC recipeants
There is always something to split. A string that doesn't contain a
separator contains one item. It doesn't matter if the string is empty or
not.

"asdf;asdf" -> two items: "asdf", "asdf"
"asdf;a" -> two items: "asdf", "a"
"asdf;" -> two items: "asdf", ""

"asdf" -> one item: "asdf"
"a" -> one item: "a"
"" -> one item: ""
CCRecipeant = txtCCEmailAddre ss.Text.Split(" ;")

'Now we need to add each one

For intCounter = 0 To CCRecipeant.Get UpperBound(0)

If CCRecipeant.Get UpperBound(0) >= 0 Then

.........some code here

End If

Next

May 12 '06 #3

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

Similar topics

2
5097
by: Jason | last post by:
I have a number of arrays that are populated with database values. I need to determine which array has the highest ubound out of all the arrays. The array size will always change based on the database record. Therefore, I need to be able to throw the arrays into a function that will automatically determine the highest ubound array. I was wondering if anyone might have a clean function that can do this. I have created a function that...
2
3869
by: Rick Brown | last post by:
I get a "subscript out of range" error when I run this code. "Rcount = rsSupplierCode.RecordCount" Returns 49 BUT "numReturned = UBound(varRecords, 2) + 1" Returns only 3 I'm I wrong to believe both should return 49? Dim dbs As DATABASE Dim qdfSupplierCode As QueryDef
3
2678
by: Andi Twine | last post by:
Hi all, I really hope someone here can help ! I have designed and built an ASP.NET web service with Visual Studio .NET. The web service outputs some dummy XML data when its called with some simple parameters. I have tested the web service on the PC it was written on (Windows XP, IIS 6, .NET 1.1, VS .NET) through the default HTTP / HTML interface with Internet Explorer. All works fine.
4
3623
by: Cindy Meister -WordMVP- | last post by:
Hi all Generally, it seems Option Strict ON is recommended practice? How, then, does one reconcile -- Option Strict On Public MyArray(6) Single 'Some Code here
2
6342
by: Starbuck | last post by:
Hi All In one of my converted (VB6 to VB.Net) apps I have managed to remove all instances of - Imports Microsoft.VisualBasic - except for one form which raises errors in regard to LBound and UBound, the code in queston is below. Private Sub ReadUsedIDs() cboIndex.Items.Clear()
4
7872
by: JR | last post by:
I may have posted a blank post accidentally. Sorry I am coming over to VB.NET from C++/C# and am confused about the UBound function. Example code: Dim i As Integer Dim myarray(6) As Integer
3
4428
by: Eugene Anthony | last post by:
<% if UBOUND(Arr) > 0 then%> <% end if %> I am getting the following error: Error Type: Microsoft VBScript runtime (0x800A000D) Type mismatch: 'UBOUND'
2
12520
by: sunshine | last post by:
I'm having trouble converting this FOR loop from VB.NET to C#: Here's the VB.NET code: Dim localCart As Object localCart = Session("cart") For i = 0 To UBound(localCart, 2) If CStr(localCart(CARTID, i)) <> "" Then orderTotal = orderTotal + (CDbl(localCart(CARTPPRICE, i)) *
4
4311
by: Mark | last post by:
What is the consensus about using the Ubound function? Should it be avoided altogether? Is there an arry size where Ubound becomes less efficent? Also, is there a better way to increase the size of an array (preserving its current values) besides using Redim Preserve? Thanks, Mark
0
8613
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
9172
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...
0
9032
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8880
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
7745
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
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3054
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
2
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.