saturnknts Posted May 14, 2006 Share Posted May 14, 2006 (edited) i have a gui with an input where the user inputs a number for a price, they then click a button and the price is multiplied against different variables and output to a label. what i would love to figure out is how to have both show thousandths comma's i.e. 1000 would equal 1,000 1000000 would be 1,000,000 any help would be appreciated, i have seen a post about a phone number input where it adds the ( ) automatically but was hoping there was an easier way. thanks in advance, tim houser Edited May 14, 2006 by saturnknts Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted May 15, 2006 Share Posted May 15, 2006 (edited) O jesus i quit quit quit quit its driving me crazy Edited May 15, 2006 by thatsgreat2345 Link to comment Share on other sites More sharing options...
Valuater Posted May 15, 2006 Share Posted May 15, 2006 (edited) use the search button at the top of this pagehttp://www.autoitscript.com/forum/index.ph...=22396&hl=,000#8) Edited May 15, 2006 by Valuater Link to comment Share on other sites More sharing options...
saturnknts Posted May 15, 2006 Author Share Posted May 15, 2006 O jesus i quit quit quit quit its driving me crazyFINE, delete my post. IF YOU THINK I AM THAT STUPID. I have been learning the new gui on my own going through almost every post, doing searches on my own and i was looking for an easy answer. i guess i should just spend another week looking around.and if you think i am a novice or afraid of hard work and determination, go look at the autoit version 1 reference examples to find my windows 95 script. look under tim houseri am sure it's something simple and i am overlooking it.i'd sure like to know how i deserve your response? if you're not going to help, why even post? Link to comment Share on other sites More sharing options...
saturnknts Posted May 15, 2006 Author Share Posted May 15, 2006 use the search button at the top of this pagehttp://www.autoitscript.com/forum/index.ph...=22396&hl=,000#8)that's what i was hoping to get as a response. as you can see by my post i was searching "thousand" and for some never thought to search "1000".thank you Valuaterand thatsgreat2345 i'm am sorry it was too much to ask, but thanks for making it feel homey around here! Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted May 15, 2006 Share Posted May 15, 2006 hahah i wasnt making fun of you i got it to work up to 100,000 just after that i couldnt not making fun of you in anyway making fun of myself now i got to go check out that post and see how the crap they did it Link to comment Share on other sites More sharing options...
saturnknts Posted May 15, 2006 Author Share Posted May 15, 2006 hahah i wasnt making fun of you i got it to work up to 100,000 just after that i couldnt not making fun of you in anyway making fun of myself now i got to go check out that post and see how the crap they did itfair enough, i am sorry i took it wrong then. just tired and stressed over all this learning!tim Link to comment Share on other sites More sharing options...
Lazycat Posted May 15, 2006 Share Posted May 15, 2006 Just another, RegExp driven variant of the same thing: Func _Thousands($nStr) If not StringIsDigit($nStr) and not StringIsFloat($nStr) then SetError(1) Return "" EndIf Local $sResult, $aResult $aResult = StringRegExp($nStr, "^(\d{1,3}?)(\d{3})+(\p\d+)?$", 1) If @extended Then $sResult = $aResult[0] For $i = 1 to UBound($aResult) - 1 $sResult &= "," & $aResult[$i] Next Else $sResult = $nStr EndIf Return StringReplace($sResult, ",.", ".") EndFunc Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
saturnknts Posted May 17, 2006 Author Share Posted May 17, 2006 (edited) i know it's clunky but here is what i came up with. it's effective and thats all i care about lol. expandcollapse popupCase $msg = $calcprice $sell = Round(($npc*2+$npcint+$npcintstr+$npcplus+$npccrit+$npcblock+$npcsos)*$pressurex) $error = GUICtrlRead($inputnpcprice) $sell2 = String($sell) Select case $error = Asc($s_char) >= 48 And Asc($s_char) <= 57 MsgBox (0, "Enter the Buy or Cost Price First!", "You must Enter the Buy or Cost Price First!") Case $sell2 <= 999 $sell3 = $sell case $sell2 <= 9999 $hund = StringRight($sell2,3) $thous = Stringleft($sell2,1) $sell3 = ($thous & "," & $hund) case $sell2 <= 99999 $hund = StringRight($sell2,3) $thous = Stringleft($sell2,2) $sell3 = ($thous & "," & $hund) case $sell2 <= 999999 $hund = StringRight($sell2,3) $thous = Stringleft($sell2,3) $sell3 = ($thous & "," & $hund) case $sell2 <= 9999999 $hund = StringRight($sell2,3) $thous = Stringmid($sell2,2,3) $mill = Stringleft($sell2,1) $sell3 = ($mill& "," & $thous & "," & $hund) case $sell2 <= 99999999 $hund = StringRight($sell2,3) $thous = Stringmid($sell2,3,3) $mill = Stringleft($sell2,2) $sell3 = ($mill& "," & $thous & "," & $hund) case $sell2 <= 999999999 $hund = StringRight($sell2,3) $thous = Stringmid($sell2,4,3) $mill = Stringleft($sell2,3) $sell3 = ($mill& "," & $thous & "," & $hund) case $sell2 >1000000000 Msgbox(0, "ummmmmmm", "Are You Crazy? That's way too much;)") EndSelect Edited May 17, 2006 by saturnknts Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 17, 2006 Moderators Share Posted May 17, 2006 (edited) Did you try LazyCats? Would have saved you alot of time and speed:MsgBox(0, '', _Thousands(100000000000.02)) Func _Thousands($nStr) If not StringIsDigit($nStr) and not StringIsFloat($nStr) then SetError(1) Return "" EndIf Local $sResult, $aResult $aResult = StringRegExp($nStr, "^(\d{1,3}?)(\d{3})+(\p\d+)?$", 1) If @extended Then $sResult = $aResult[0] For $i = 1 to UBound($aResult) - 1 $sResult &= "," & $aResult[$i] Next Else $sResult = $nStr EndIf Return "$" & StringReplace($sResult, ",.", ".") EndFuncUsing LazyCat's UDF Edited May 17, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
saturnknts Posted May 17, 2006 Author Share Posted May 17, 2006 my mind was to full of things and this was the easiest was i could decide to do it and make sense in my mind. but now that my program is complete i might go back and test it once again so as to reduce a little bit of code. tim Did you try LazyCats? Would have saved you alot of time and speed:MsgBox(0, '', _Thousands(100000000000.02)) Func _Thousands($nStr) If not StringIsDigit($nStr) and not StringIsFloat($nStr) then SetError(1) Return "" EndIf Local $sResult, $aResult $aResult = StringRegExp($nStr, "^(\d{1,3}?)(\d{3})+(\p\d+)?$", 1) If @extended Then $sResult = $aResult[0] For $i = 1 to UBound($aResult) - 1 $sResult &= "," & $aResult[$i] Next Else $sResult = $nStr EndIf Return "$" & StringReplace($sResult, ",.", ".") EndFuncUsing LazyCat's UDF Link to comment Share on other sites More sharing options...
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