Merchants Posted October 22, 2014 Posted October 22, 2014 i want to replace smaller numbers into large number and i can't do it with one string replace or i need to stack it up but that is not so economic so i need a better func for it ;input = test 2 StringReplace(StringReplace("test 2", "2","1"), " ","-") ;Output = test-1 when i create a input text i want to put it in a generator so that i get a output that i want some examples below: input = "5k" -> i want to see a output of: 5000 and some more examples: 5k -> 5000 1k -> 1000 2,2k -> 2200 1m -> 1000000 and i also like to convert it backwords 5000 -> 5k 1000 -> 1k 2200 -> 2,2k etc...
kylomas Posted October 22, 2014 Posted October 22, 2014 Merchants, Completely define the sets of: measurements symbols equating to those measurements Then it should not be too hard to put something together. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
Solution Merchants Posted October 23, 2014 Author Solution Posted October 23, 2014 (edited) Found it my self: $number="100k" Msgbox(64,"input", "input: " & $number) If StringRegExp($number,"k") Then $R = StringReplace(StringReplace(StringReplace($number, ",","."), " ",""), "k","")*1000 ElseIf StringRegExp($number,"m") Then $R = StringReplace(StringReplace(StringReplace($number, ",","."), " ",""), "m","")*1000000 Else $R = StringReplace($number, ",",".") EndIf Msgbox(64,"output", "output: " & $R) ; -> From small to large numbers $number="100000" Msgbox(64,"input", "input: " & $number) If ($number > 9999 And $number < 999999) Then $R = $number/1000 & "k" ElseIf $number > 999999 Then $R = $number/1000000 & "m" Else $R = $number EndIf Msgbox(64,"output", "output: " & $R) ; -> From large to smaller numbers Edited October 23, 2014 by Merchants
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now