Results 1 to 4 of 4

Thread: Function

  1. #1

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    Cool

    I have a few hundre files with weird names.
    ie. Trying To Find A Few Hundred Dollars
    Special Things To Do If You Are Dead

    I would like to convert the file names to
    the first letter of each word.
    ie. ttfafhd
    sttdiyad

    How do I manipulate the strfunction or whatever to do such a thing.

    Thanks,
    Wayne

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    The following code should do it for you. I am sure someone else out there has a better method, but this one works.

    Code:
        Dim myStr As String
        Dim newStr As String
        Dim i As Long
        
        i = 1
        myStr = "Example Showing How To Get The First Charcter In Each Word In A String"
    
        myStr = Trim$(myStr)
        
        'get the first character.
        newStr = Mid$(myStr, 1, 1)
        
        'loop while there is a space in the string
        While i <> 0
          i = InStr(i, myStr, " ")
          If (i <> 0) Then
            i = i + 1
            newStr = newStr & Mid$(myStr, i, 1)
          End If
        Wend
        
        MsgBox newStr
    Iain, thats with an i by the way!

  3. #3
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516

    Lightbulb I think I've got a vague idea...

    Well.I've never done anything like this before, but te very base code would go *something* like this:

    Code:
    Dim strAcronym() as String, strFinal as String, i as Integer
    
    strFinal = ""
    strAcronym = Split(thefilename, " ")
    
    For i = 0 to UBound(strAcronym)
        strFinal = strFinal & Chr(Asc(strAcronym(i)))
    Next:
    
    [newfilename] = strFinal
    Hmmm. Well that's as far as I know how to go.

    Hope I've helped.

    Au revoir.

    Me.
    Courgettes.

  4. #4

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946
    Thanks...should do the trick...I'll give it a whirl when I get home.

    Wayne

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