|
-
Nov 8th, 2000, 10:22 PM
#1
Thread Starter
Lively Member
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"
-
Nov 8th, 2000, 10:28 PM
#2
Frenzied Member
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]
-
Nov 8th, 2000, 10:52 PM
#3
Thread Starter
Lively Member
hey thats great
thank you....
but where do i place this code that you have given me
-
Nov 8th, 2000, 10:58 PM
#4
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
-
Nov 8th, 2000, 11:01 PM
#5
Frenzied Member
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!
-
Nov 8th, 2000, 11:07 PM
#6
Thread Starter
Lively Member
thats amazing great man!!!!!!
thats amazing great man!!!!!!thats amazing great man!!!!!!thats amazing great man!!!!!!
-
Nov 8th, 2000, 11:31 PM
#7
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|