Results 1 to 5 of 5

Thread: String Split Headache

Threaded View

  1. #3

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    3

    Re: String Split Headache

    I did a little more coding and came up with how I wanted to use this, but it throws a bunch of exceptions at me, even though the code works fine.

    Code:
     totalPriceString = totalPrice.ToString
                Dim priceArray() = totalPriceString.Split("."c)
    
                If ((priceArray IsNot Nothing) And (UBound(priceArray) = 0)) Then ' I have no decimals
                    totalPriceString = totalPrice.ToString & ".00"
                    salesTaxString = salesTax.ToString & ".00"
                ElseIf ((priceArray IsNot Nothing) And (UBound(priceArray) = 1)) Then ' I have one or two decimals already
                    If (priceArray(1).Length = 1) Then
                        totalPriceString = totalPrice.ToString & "0"
                        salesTaxString = salesTax.ToString & "0"
                    End If
                End If
    The exceptions:

    Code:
    A first chance exception of type 'System.IndexOutOfRangeException' occurred
    A first chance exception of type 'System.NullReferenceException' occurred
    A first chance exception of type 'System.NullReferenceException' occurred
    A first chance exception of type 'System.NullReferenceException' occurred
    A first chance exception of type 'System.NullReferenceException' occurred
    A first chance exception of type 'System.NullReferenceException' occurred
    A first chance exception of type 'System.IndexOutOfRangeException' occurred
    A first chance exception of type 'System.IndexOutOfRangeException' occurred
    A first chance exception of type 'System.IndexOutOfRangeException' occurred
    A first chance exception of type 'System.IndexOutOfRangeException' occurred
    I understand what the exceptions mean, just not why I am getting them in this case when I specifically checked to prevent them...
    Last edited by Rajada; May 11th, 2012 at 05:47 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width