Home All Groups Group Topic Archive Search About
Author
3 Aug 2006 1:27 PM
Condeh
Hi There

Im looking to do something, although im not sure if its possible.

Say for instance, the word "Fred" the numerical value of that word is
"6+18+5+4 = 33"

Is there anything i can do to get a phrase such as "humpty dumpty sat
on the wall" converted into number, and then added together?

Thanks for any help!

Author
3 Aug 2006 2:14 PM
iwdu15
i think youl have to write your own function to do that
--
-iwdu15
Author
3 Aug 2006 2:14 PM
Phill W.
Condeh wrote:

> Say for instance, the word "Fred" the numerical value of that word is
> "6+18+5+4 = 33"

How about this?

Function AddUp( ByVal sText As String ) As Integer

    Const kSet As String = "abcdefghijklmnopqrstuvwxyz"
    Dim iTotal As Integer = 0

    For iSub As Integer = 0 To sText.Length - 1
       Dim iPos As Integer _
          = kSet.IndexOf( sText.SubString( iSub, 1 ).ToLower() )

       If iPos > -1 Then
          iTotal = iTotal + ( iPos + 1 )
       End If
    Next

    Return iTotal
End Function

? AddUp( "Fred" )
33
? AddUp( "humpty dumpty sat on the wall" )
352

HTH,
    Phill  W.
Author
3 Aug 2006 4:08 PM
Mythran
Show quote Hide quote
"Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-k> wrote in message
news:eat0bk$dv8$1@south.jnrs.ja.net...
> Condeh wrote:
>
>> Say for instance, the word "Fred" the numerical value of that word is
>> "6+18+5+4 = 33"
>
> How about this?
>
> Function AddUp( ByVal sText As String ) As Integer
>
>    Const kSet As String = "abcdefghijklmnopqrstuvwxyz"
>    Dim iTotal As Integer = 0
>
>    For iSub As Integer = 0 To sText.Length - 1
>       Dim iPos As Integer _
>          = kSet.IndexOf( sText.SubString( iSub, 1 ).ToLower() )
>
>       If iPos > -1 Then
>          iTotal = iTotal + ( iPos + 1 )
>       End If
>    Next
>
>    Return iTotal
> End Function
>
> ? AddUp( "Fred" )
> 33
> ? AddUp( "humpty dumpty sat on the wall" )
> 352
>
> HTH,
>    Phill  W.

Good example, the OP should know that "ABCDEFG1234" will return the same
value as "ABCDEFG" :D

Mythran
Author
3 Aug 2006 10:19 PM
eSolTec, Inc. 501(c)(3)
My question is: Does each letter or word have a value associated with it?

If so, a CaseSelect statement would work, wouldn't it? Assign a value for
each character/word and when that character or word is used create an
equation?

Michael

Show quoteHide quote
"Mythran" wrote:

>
> "Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-k> wrote in message
> news:eat0bk$dv8$1@south.jnrs.ja.net...
> > Condeh wrote:
> >
> >> Say for instance, the word "Fred" the numerical value of that word is
> >> "6+18+5+4 = 33"
> >
> > How about this?
> >
> > Function AddUp( ByVal sText As String ) As Integer
> >
> >    Const kSet As String = "abcdefghijklmnopqrstuvwxyz"
> >    Dim iTotal As Integer = 0
> >
> >    For iSub As Integer = 0 To sText.Length - 1
> >       Dim iPos As Integer _
> >          = kSet.IndexOf( sText.SubString( iSub, 1 ).ToLower() )
> >
> >       If iPos > -1 Then
> >          iTotal = iTotal + ( iPos + 1 )
> >       End If
> >    Next
> >
> >    Return iTotal
> > End Function
> >
> > ? AddUp( "Fred" )
> > 33
> > ? AddUp( "humpty dumpty sat on the wall" )
> > 352
> >
> > HTH,
> >    Phill  W.
>
> Good example, the OP should know that "ABCDEFG1234" will return the same
> value as "ABCDEFG" :D
>
> Mythran
>
>
>
Author
4 Aug 2006 1:46 PM
Condeh
Wow, thats spot on, thanks very much, I'll now try and mkae sense of it
all!

Thanks again!
Phill W. wrote:
Show quoteHide quote
> Condeh wrote:
>
> > Say for instance, the word "Fred" the numerical value of that word is
> > "6+18+5+4 = 33"
>
> How about this?
>
> Function AddUp( ByVal sText As String ) As Integer
>
>     Const kSet As String = "abcdefghijklmnopqrstuvwxyz"
>     Dim iTotal As Integer = 0
>
>     For iSub As Integer = 0 To sText.Length - 1
>        Dim iPos As Integer _
>           = kSet.IndexOf( sText.SubString( iSub, 1 ).ToLower() )
>
>        If iPos > -1 Then
>           iTotal = iTotal + ( iPos + 1 )
>        End If
>     Next
>
>     Return iTotal
> End Function
>
> ? AddUp( "Fred" )
> 33
> ? AddUp( "humpty dumpty sat on the wall" )
> 352
>
> HTH,
>     Phill  W.