Results 1 to 7 of 7

Thread: For the Gurus***----String Manipulation---****

  1. #1

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92

    Exclamation

    hey guys, for the past few days i have been doing stuff with strings, but now i have a different problem. i need to take a sentence inside a textbox: then take the first letter and move it to the end of the word, then add the letters "ay" at the end of the word.

    i.e the sentence: my name is mykg4orce.

    it should look like this after:

    ymay amenay siay ykg4orcemay

    y m "ay" ame n "ay" s i "ay" ykg4orce m "ay"

  2. #2
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    here ya go

    Code:
    Function EditString(ByVal sStr$) As String
    Dim i As Integer
    Dim FirstChr As String
    
    FirstChr = Left(sStr, 1)
    sStr = Right(sStr, Len(sStr) - 1)
    
    sStr = sStr & FirstChr & "ay"
    EditString = sStr
    End Function
    That would do more than one word though.
    Did you want something to do more than
    one word?

    [Edited by Evan on 11-08-2000 at 10:36 PM]

  3. #3

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92

    Exclamation hey thats great

    thank you....

    but where do i place this code that you have given me

  4. #4
    Guest
    Ig you're going to do it, you may as well do it properly. The rule for pig english is to only move the first letter to the end of the word if the letter is a consonant, and not a vowel. Therefore:

    name = amenay
    boris = orisbay
    is = isay <---- Note: first letter not moved
    explain = explainay



    - gaffa

  5. #5
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    Let me point you in the right direction.
    You need to go look at http://www.planet-source-code.com
    Then search for pig latin and I swear you
    will find what you are looking for!

    Give that a shot!

  6. #6

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92

    Exclamation thats amazing great man!!!!!!

    thats amazing great man!!!!!!thats amazing great man!!!!!!thats amazing great man!!!!!!

  7. #7
    Member
    Join Date
    Aug 1999
    Location
    Houston
    Posts
    48

    dynamarray = Split(StringOfWords, " ")
    NumberOfWords = UBound(dynamarray) + 1
    Dim buffer() As String
    ReDim buffer(1 To NumberOfWords)
    buffer = Split(StringOfWords, " ", NumberOfWords)

    ReDim WordArray(NumberOfWords)

    For j% = 1 To NumberOfWords
    WordArray(j%) = buffer(j% - 1)
    Next j%


    For j% = 1 To NumberOfWords
    'get length of word j%
    wordlen=Len(WordArray(j%))
    'get first letter of word
    FirstLetter=left(WordArray(j%),1)
    'only use right side of word equal to length-1
    wordarray(j%)=Right(WordArray(j%),wordlen-1) & FirstLetter
    wordArray(j%)=WordArray(j%) & "ay"
    Next j%


    ------
    this should do. There's actually many ways to do this. Look up the len, instr, and right commands. To pull off
    words form a single string of words, first search for the first occurrence of a space with Instr(wordarray," "). Say the first space " " is at position 5. Thus, the first word is 4 letters long. Next, pull off the first word with the command left(wordstring,4). Then select the remainder of the string to the right by subtracting 5 form the length as in

    right(wordstring,len(wordstring)-5)

    Basically, all you need to do is look up these commands in your reference manual.

    -lp

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