|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
UBound behaviourThe thing is, even if txtCCEmailAddress.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 = txtCCEmailAddress.Text.Split(";") 'Now we need to add each one For intCounter = 0 To CCRecipeant.GetUpperBound(0) If CCRecipeant.GetUpperBound(0) >= 0 Then ..........some code here End If Next Thanks, Adam 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.Binary ) 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 txtCCEmailAddress.Text for length first? Fred Adam Honek wrote:
> I have the following code below. No, it wont. If the string is empty, the array will contain one item, so > > The thing is, even if txtCCEmailAddress.Text is empty (no text), CCRecipeant > will return a Ubound() higher than 0 and still go in the loop. 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? There is always something to split. A string that doesn't contain a > 'Get the number of specified CC recipeants 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: "" Show quoteHide quote > CCRecipeant = txtCCEmailAddress.Text.Split(";") > > 'Now we need to add each one > > For intCounter = 0 To CCRecipeant.GetUpperBound(0) > > If CCRecipeant.GetUpperBound(0) >= 0 Then > > .........some code here > > End If > > Next
Alternative to OpenFileDialog?
ToolStrip with ToolStripDropDownButton Regex references NULL Value - Specified cast is not valid Serial Port - How To Use "Invoke" On The Second Thread Beginner- 2 Forms & Events Different Events File access issue Enabling STAThreadAttribute Passing data between forms: tag is ok? |
|||||||||||||||||||||||