View Full Version : strReverse()
ShMiL
12-05-2002, 11:52 AM
When I use this:
strReverse("I just bought 60 packs")
I get:
"skcap 06 thguob tsuj I"
Everything's reversed as it should be.
How can I only reverse the alpha chars' without reversing the numeric chars'?
Thus, the output would be:
"skcap 60 thguob tsuj I"
Anyone has an idea?
Thanks
rcreyes
12-05-2002, 02:51 PM
This is one way to do it:
sStr="I just bought 60 packs"
sArray = Split(sStr)
For j = 0 to Ubound(sArray)
bNumberFlag = False
For i = 1 to Len(sArray(j) )
If Instr("0123456789", Mid(sArray(j),i,1) ) > 0 Then
bNumberFlag = True
Exit For
End If
Next
If NOT bNumberFlag Then
sArray(j) = strReverse ( sArray(j) )
End If
Next
'-- put it together
For j = Ubound(sArray) to 0 Step -1
s = s & sArray(j) & " "
Next
Msgbox Left(s, Len(s)-1)
Please note that this will not work if the number is mixed with chars, i.e.
This is 20Dozens of eggs
But will work if the data is:
This is 20 Dozens of eggs
Thanks,
Ray
ShMiL
12-05-2002, 03:21 PM
Thanks Ray!
This is not solving... (Hebrew is a tough language...)
But I think :rolleyes: you gave me the right direction.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.