 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Mountie
Joined: 30 Oct 2007 Posts: 13
|
Posted: Sat Mar 08, 2008 3:25 am Post subject: Stripping out commas from a string |
|
|
I'm having problems elminating commas from a text input string.
The input variable value is txtVar1 = 1,234. How can this string
be modified so that the variable txtVar1 will contain the value 1234 |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 666 Location: MN, USA
|
Posted: Sat Mar 08, 2008 4:20 am Post subject: |
|
|
| Code: | var=1,234
StringReplace, var, var, `,,, UseErrorLevel
MsgBox, %var% `n %ErrorLevel% commas were replaced. |
_________________ http://autohotkey.net/~jaco0646/ |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1494
|
Posted: Sat Mar 08, 2008 8:06 am Post subject: |
|
|
| Code: | String = the national debt ~= 9,400,000,000.00, and all americans have to pay it, eventually (1 , 2).
Loop, parse, String
{
If (A_LoopField + 1)
InANumber = yes
If (A_LoopField = "," && InANumber = "yes")
continue
If !(A_LoopField + 1)
InANumber = no
NewString .= A_LoopField
}
msgbox %NewString% | Removes all commas that appear immediately after a nunmberal. plz forgive my coding as I am drunk ATM. _________________ My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags ! |
|
| Back to top |
|
 |
Oberon
Joined: 18 Feb 2008 Posts: 453
|
Posted: Sat Mar 08, 2008 10:44 am Post subject: |
|
|
As jaco0646 demonstrated StringReplace can be used for this...
| Code: | txtVar1 = 1,234
StringReplace, txtVar1, txtVar1, `,, , All
MsgBox, %txtVar1% |
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|