Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sum
Message
 
À
04/07/2004 03:24:15
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Re: Sum
Divers
Thread ID:
00918691
Message ID:
00920707
Vues:
25
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform