How can I do this (strings).
Say I have a string called String1 of a fixed size which contains "1 2 3" and a string called String2 also of a fixed size. What I want to do is copy the contents of String1 into String2, but replace '1' with "one", '2' with "two", etc.
It's simple to replace it with one character, but if I do something like:
String2 = 'o'; String2 = 'n', etc. then parts will be overwritten. So do I need to move it all along or what? Sorry if this is a bit vague, but I have no idea how to do this.
Thanks <img src="smile.gif" width=15 height=15 align=middle>
Edited by - Quantum on 12/25/00 3:41:21 AM
I think u better use pre-defined array of definitions of numbers like this:
dim String1 as String
dim String2 as String
get string1 from user
then u say to use that the max number is such( say, 10000):
if len(string1)>=6 then message to user that "number is to big"
else
select case len(string1)
case is =1
call FirstDigit
case is =2
call SelectDigit
case is =3
call ThirdDigit
case is =4
call FourthDigit
case is =5
Call FifthDigit
end select
ur firstdigit..
Public Sub First Digit()
''define ur array of first digits as
dim FirstDigits(0 to 9) as string
firstdigits(0)="Zero"
firstdigits(1)="one"
and so on
end sub
Public Sub Second Digit( )
dim SecondDigits(0 to 9) as string
seconddigits(0)="ten"
seconddigits(1)="eleven"
and so on till "nineteen"
select case left(string1,1)
case is = "2"
string2="Twenty" & firstdigit(val(left(string1,2)))
case is ="3"
string2="Thirty" & firstdigit(val(left(string1,2)))
case is = "4"
string2="Fourty" & firstdigit(val(left(string1,2)))
and so on until 9
end select
end sub
Public Sub Third Digit( )
select case left(string1,1)
case is ="1"
string2= firstdigit(val(left(string1,1))) & "Hundred" & SecondDigit(val(right(left(string1,2),1))
case is = "2"
string2= firstdigit(val(left(string1,1))) & "Hundred" & SecondDigit(val(right(left(string1,2),1))
end select
end sub
Public Sub Fourth Digit( )
end sub
Public Sub Fifth Digit()
end sub
And so on.. u get the idea? )
dim String1 as String
dim String2 as String
get string1 from user
then u say to use that the max number is such( say, 10000):
if len(string1)>=6 then message to user that "number is to big"
else
select case len(string1)
case is =1
call FirstDigit
case is =2
call SelectDigit
case is =3
call ThirdDigit
case is =4
call FourthDigit
case is =5
Call FifthDigit
end select
ur firstdigit..
Public Sub First Digit()
''define ur array of first digits as
dim FirstDigits(0 to 9) as string
firstdigits(0)="Zero"
firstdigits(1)="one"
and so on
end sub
Public Sub Second Digit( )
dim SecondDigits(0 to 9) as string
seconddigits(0)="ten"
seconddigits(1)="eleven"
and so on till "nineteen"
select case left(string1,1)
case is = "2"
string2="Twenty" & firstdigit(val(left(string1,2)))
case is ="3"
string2="Thirty" & firstdigit(val(left(string1,2)))
case is = "4"
string2="Fourty" & firstdigit(val(left(string1,2)))
and so on until 9
end select
end sub
Public Sub Third Digit( )
select case left(string1,1)
case is ="1"
string2= firstdigit(val(left(string1,1))) & "Hundred" & SecondDigit(val(right(left(string1,2),1))
case is = "2"
string2= firstdigit(val(left(string1,1))) & "Hundred" & SecondDigit(val(right(left(string1,2),1))
end select
end sub
Public Sub Fourth Digit( )
end sub
Public Sub Fifth Digit()
end sub
And so on.. u get the idea? )
" Do we need us? "Ionware Productions - Games and Game Tools Development
Um, sorry, I should have mentioned I was trying to do this in C++. VB looks completely alien to me too
Hope this is what you mean,
if str1 contains "1 2 5 1 6 7", then
str2 will containt "one two five one six seven".
Hope this helped
/ Tooon
Edited by - Tooon on December 25, 2000 7:00:09 PM
Edited by - Tooon on December 25, 2000 7:01:59 PM
if str1 contains "1 2 5 1 6 7", then
str2 will containt "one two five one six seven".
|
Hope this helped
/ Tooon
Edited by - Tooon on December 25, 2000 7:00:09 PM
Edited by - Tooon on December 25, 2000 7:01:59 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement