Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to switch a char to the end of the word

Status
Not open for further replies.

honeymao

Programmer
Sep 17, 2003
1
US
How could you locate any consonant character( before any volwel) to the end of the word?
Exaple: throught - oughtthr
now - own
 
Dim Palabra, Firstl
Palabra = "now"
Firstl = LCase(Left(Palabra, 1))
If Not Firstl = "a" Or Not Firstl = "e" Or Not Firstl = "i" Or Not Firstl = "o" Or Not Firstl = "u" Then
Palabra = Right(Palabra, Len(Palabra) - 1) & Firstl
End If
MsgBox Palabra


peterguhl@yahoo.de
 
Sorry Poltergeist, Your code only works for the first letter of the string.

Lo Siento Poltergeist, su codigó funcionamente solo para la primera letra del palabra.

The code below will work.

[tt]
Private Sub Command1_Click()
Dim strWord As String
Dim CurChar As String
Dim WordLoop As Integer
Dim TempCons As String
Dim TempVowel As String

'Change to your word or string reference
strWord = "Throughout"

For WordLoop = 1 To Len(strWord)
CurChar = Mid(strWord, WordLoop, 1)
Select Case UCase(CurChar)
Case "A", "E", "I", "O", "U"
TempVowel = TempVowel & CurChar
Case Else
TempCons = TempCons & CurChar
End Select
Next WordLoop

strWord = TempVowel & TempCons
MsgBox strWord 'or place strWord where you want

End Sub
[tt]


yoshiweb.gif


"I'm an idealist. I don't know where I'm going but I'm on the way." — Carl Sandburg, 20th-century American poet and writer
 
Sorry Yoshi understand like if the first char is any konsonant, but you can do it in a Loop.

Discuple Yoshi tenia entendido que el quiere mover la primera letra al final cuando es un consonant. Tal igual sirve cuando tu lo haces en un civlo repetitivo.

Entschuldige Yoshi hatte verstanden, dass er nur den ersten Buchstaben ans Ende verschieben will wenn es ein Konsonant ist. Trotzdem geht die Routine wenn es als schleife gelegt wird.

Dim Palabra, Firstl
Palabra = "Throughout"
Firstl = LCase(Left(Palabra, 1))
Do While Not Firstl = "o" And Not Firstl = "e" And Not Firstl = "i" And Not Firstl = "o" And Not Firstl = "u"
Palabra = Right(Palabra, Len(Palabra) - 1) & Firstl
Firstl = LCase(Left(Palabra, 1))
Loop
MsgBox Palabra


peterguhl@yahoo.de
 
Bug - Line

Do While Not Firstl = "a" And Not Firstl = "e" And Not Firstl = "i" And Not Firstl = "o" And Not Firstl = "u"

peterguhl@yahoo.de
 
Poltergeist,

¡Yo entiendo ahora!
I Understand Now!
(Sorry, haven't quite learnt Deutsch just yet!)

Very impressed at your knowledge of languages. (I Speak only English, Spanish and Japanese)

Your code works fine for the first consonant, however Honeymao (i hope) requires that all vowels be at the beginnning of the word and all consonants at the end, in ascending order. (i take this from her examples!)

Regards,




yoshiweb.gif


"I'm an idealist. I don't know where I'm going but I'm on the way." — Carl Sandburg, 20th-century American poet and writer
 
Correction... I made a large assumption that Honeymao is female!!!

I apologise honeymao, whatever gender you happen to be!

Regards,


yoshiweb.gif


"I'm an idealist. I don't know where I'm going but I'm on the way." — Carl Sandburg, 20th-century American poet and writer
 
Dim Wort1, VoPos, Vocal, i, BuchS
Wort1 = "Throughout"
Vocal = Array("a", "e", "i", "o", "u")
VoPos = Len(Wort1)
For i = LBound(Vocal) To UBound(Vocal)
BuchS = InStr(1, Wort1, Vocal(i))
If BuchS < VoPos And BuchS <> 0 Then VoPos = BuchS
Next i
MsgBox &quot;first &quot; & vbTab & Mid(Wort1, VoPos) & Left(Wort1, VoPos - 1) & vbCrLf & _
&quot;second&quot; & vbTab & Mid(Wort1, VoPos) & StrReverse(Left(Wort1, VoPos - 1))
MsgBox VoPos


peterguhl@yahoo.de
 
Poltergeist,

Again your response doesn't get all of the vowels to the start of the word, maybe you missed the point. Sorry.

Regards,


yoshiweb.gif


&quot;I'm an idealist. I don't know where I'm going but I'm on the way.&quot; — Carl Sandburg, 20th-century American poet and writer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top