Results 1 to 4 of 4

Thread: [RESOLVED] String Manipulation

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    38

    Resolved [RESOLVED] String Manipulation

    I am trying to create a program to do a function, when the client provides the name, it is supposed to look in a directory using a formula.
    If the name of the customer is Jack, then it is supposed to do the ASCII of upper case of JACK then add J + A + C + K then divide by 256 and the remainder is the folder name. I am having quite a hard time doing this in VB, any help is much appreciated.

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: String Manipulation

    Welcome to the forums

    Is this what you were after?:
    Code:
    Option Explicit
    
    Private Sub Form_Load()
        Debug.Print total("Jack")
    End Sub
    
    Function total(strWord As String) As Double
        Dim lngN As Long
        Dim dblTemp As Double
    
        strWord = UCase$(strWord)
    
        For lngN = 1 To Len(strWord)
            dblTemp = (dblTemp + Asc(Mid$(strWord, lngN, 1)))
        Next lngN
    
        total = (dblTemp / 256)
    End Function

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    38

    Resolved Re: String Manipulation

    Thank you so much for your post
    Yep, it's almost exactly what i was looking for except i wanted the remainder also but I figured that out.

    Thanks once again

  4. #4

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