Jump to content
Sign in to follow this  

replace value

Recommended Posts

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


Share this post

Link to post
Share on other sites


Completely define the sets of:

  1. measurements
  2. symbols equating to those measurements


Then it should not be too hard to put something together.


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

Share this post

Link to post
Share on other sites

Found it my self:


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
    $R = StringReplace($number, ",",".")
Msgbox(64,"output", "output: " & $R)
; -> From small to large numbers

Msgbox(64,"input", "input: " & $number)
If ($number > 9999 And $number < 999999) Then
    $R = $number/1000 & "k"
ElseIf $number > 999999 Then
    $R = $number/1000000 & "m"
    $R = $number
Msgbox(64,"output", "output: " & $R)
; -> From large to smaller numbers
Edited by Merchants

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...