Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sum
Message
 
To
04/07/2004 03:24:15
General information
Forum:
ASP.NET
Category:
Other
Title:
Re: Sum
Miscellaneous
Thread ID:
00918691
Message ID:
00920707
Views:
27
Hello Mohammed,

yes your code is right but just to make sure, here is the complete code you need.

(BTW, are you in VB.NET or VB6?)
    Function SumStringChars(ByVal strStringToSum As String) As Integer

        Dim chrCharToSum As Char
        Dim i As Integer
        Dim intResult As Integer = 0

        Try
            For i = 0 To strStringToSum.Length - 1
                chrCharToSum = strStringToSum.Chars(i)

                If Not Char.IsDigit(chrCharToSum) Then
                    Throw New ArgumentException
                End If

                intResult += Val(chrCharToSum)
            Next

            Return intResult

        Catch ex As Exception
            Throw
        End Try
    End Function

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        TextBox2.Text = SumStringChars(TextBox1.Text)
    End Sub
Hope that helps,
Alex
Alexandre Boudreault-Ferland
Chief Technology Officer
AZUR Technologies
http://www.xicommunity.ca
http://www.xiazur.com
http://endfunction.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform