KickStarter15 Posted November 15, 2018 Share Posted November 15, 2018 (edited) Hi Experts, I need your idea and help on this new task I have. Problem is how can I add +1 in each number like 123 until it reaches back to 123. I have my example below: Input number is 123 range is from 0-9. Results: 123 234 345 456 567 678 789 890 901 012123 As you can see above input number is 123 and then each number was added with plus 1 until it reaches back to 123. Sadly, i tried googling and checking help file for hint but I can't find any. If you can provide link for me to start then it would be great. I only made my GUI because I can't proceed due to less idea how. Please need your help Experts. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 343, 269, 192, 124) $Input1 = GUICtrlCreateInput("", 106, 15, 97, 21) $Edit1 = GUICtrlCreateEdit("", 18, 50, 305, 201) GUICtrlSetData(-1, "") $Label1 = GUICtrlCreateLabel("Tracking Number:", 14, 18, 89, 17) $Button1 = GUICtrlCreateButton("Generate", 218, 11, 89, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ; here is the missing code I don't really know how to start. Sorry Experts! EndSwitch WEnd Thanks in advance, Experts! KS15 Edited November 26, 2018 by KickStarter15 Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
Deye Posted November 15, 2018 Share Posted November 15, 2018 (edited) KickStarter15, So, when you click Generate what needs to happen ? what number should come after 901 what is the format you need as in ###-###-### Deye Edited November 15, 2018 by Deye Link to comment Share on other sites More sharing options...
careca Posted November 15, 2018 Share Posted November 15, 2018 (edited) expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 343, 269, 192, 124) $Input1 = GUICtrlCreateInput("", 106, 15, 97, 21) $Edit1 = GUICtrlCreateEdit("", 18, 50, 305, 201) GUICtrlSetData(-1, "") $Label1 = GUICtrlCreateLabel("Tracking Number:", 14, 18, 89, 17) $Button1 = GUICtrlCreateButton("Generate", 218, 11, 89, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $a=1, $b=2, $c=3, $String While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 While 1 For $i = 0 To 9 If $i= 8 Then $String = 890 ElseIf $i= 9 Then $String = 901 Else $String = $i&$i+1&$i+2 EndIf ConsoleWrite($String&@CRLF) Sleep(100) Next WEnd EndSwitch WEnd could not think of a way to work out those bigger numbers, without these 2 conditions, it outputs the wrong numbers, 10 and 11. Edited November 15, 2018 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Malkey Posted November 15, 2018 Share Posted November 15, 2018 This appears to work. Local $num = "64704", $NewNum = $num, $NewNum1, $sRet = $num & @CRLF For $i = 1 To 10 For $j = 1 To StringLen($num) $NewNum1 &= StringRight(StringMid($NewNum, $j, 1) + 1, 1) Next $sRet &= $NewNum1 & @CRLF $NewNum = $NewNum1 $NewNum1 = "" Next MsgBox(0, "Result", "Starting number: " & $num & @CRLF & @CRLF & $sRet) KickStarter15 1 Link to comment Share on other sites More sharing options...
KickStarter15 Posted November 15, 2018 Author Share Posted November 15, 2018 Thanks @Malkey. This is the one thing that I want to happen. Thank you so much. @Deye, Here's the format of my post. When it reaches back to 123, the program stop. means the program reaches 0-9 in each number. Anyways, thank you for responding Deye 1 Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
Deye Posted November 15, 2018 Share Posted November 15, 2018 must have misread , Oops Again Link to comment Share on other sites More sharing options...
Skeletor Posted November 15, 2018 Share Posted November 15, 2018 (edited) Abit late but with another version... expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 343, 269, 192, 124) $Input1 = GUICtrlCreateInput("", 106, 15, 97, 21) _GUICtrlEdit_SetLimitText ( $Input1, 3) $Edit1 = GUICtrlCreateEdit("", 18, 50, 305, 201, $ES_MULTILINE) ;_GUICtrlEdit_SetLimitText ( $Edit1, 3) GUICtrlSetData(-1, "") $Label1 = GUICtrlCreateLabel("Tracking Number:", 14, 18, 89, 17) $Button1 = GUICtrlCreateButton("Generate", 218, 11, 89, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 PlusOne() EndSwitch WEnd Func PlusOne() $ReadInput = GUICtrlRead($Input1) $first = StringLeft($ReadInput,1) +1 $second = StringMid($ReadInput,2,1) +1 $third = StringRight($ReadInput,1) +1 If $first > 9 Then $first = 0 EndIf If $second > 9 Then $second = 0 EndIf If $third > 9 Then $third = 0 EndIf GUICtrlSetData($Edit1, $first & $second & $third & @CRLF, 1) GUICtrlSetData($Input1,$first & $second & $third) EndFunc Edited November 15, 2018 by Skeletor Kind RegardsSkeletor "Coffee: my defense against going postal." Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI Link to comment Share on other sites More sharing options...
KickStarter15 Posted November 15, 2018 Author Share Posted November 15, 2018 9 minutes ago, Deye said: must have misread , Oops Again Yeah, I also did that many times as well.. Late to realized @Skeletor, yup you got it right, thanks men. However, I need to input the tracking number and it only shows single count. I need the result just like malkey's response. Thanks anyway. Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
boomingranny Posted November 15, 2018 Share Posted November 15, 2018 expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 343, 269, 192, 124) $Input1 = GUICtrlCreateInput("", 106, 15, 97, 21) $Edit1 = GUICtrlCreateEdit("", 18, 50, 305, 201) GUICtrlSetData(-1, "") $Label1 = GUICtrlCreateLabel("Tracking Number:", 14, 18, 89, 17) $Button1 = GUICtrlCreateButton("Generate", 218, 11, 89, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $chrSet = "01234567890" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUICtrlSetData($Button1,"Generating...") GUICtrlSetState($Button1,$GUI_DISABLE ) $match = GUICtrlRead($Input1) $Result = $match&@CRLF $newString = $match do ConsoleWrite($newString&@CRLF) $chr = StringSplit($newString,"") $newString = "" For $i = 1 To $chr[0] $loc = StringInStr($chrSet,$chr[$i]) $replaceWithChr = StringMid($chrSet,$loc+1,1) $newString&=$replaceWithChr Next $Result &= $newString&@CRLF Until $newString = $match GUICtrlSetData($Edit1,$Result) GUICtrlSetState($Button1,$GUI_ENABLE ) GUICtrlSetData($Button1,"Generate") EndSwitch WEnd Link to comment Share on other sites More sharing options...
mikell Posted November 15, 2018 Share Posted November 15, 2018 ... and regex version of Malkey's code Local $num = "64704", $new = $num, $sRet = $num & @CRLF For $i = 1 To 10 $new = Execute(StringRegExpReplace($new, '(\d)', " Mod('$1'+1, 10) & ") & "''") $sRet &= $new & @CRLF Next MsgBox(0, "Result", "Starting number: " & $num & @CRLF & @CRLF & $sRet) careca, FrancescoDiMuro, KickStarter15 and 1 other 4 Link to comment Share on other sites More sharing options...
Nine Posted November 15, 2018 Share Posted November 15, 2018 (edited) with whatever lenght is the initial string or whatever value is the initial string : $InitialString = "1234" $i = StringMid ($InitialString,1,1) $len = StringLen ($InitialString) For $n = 0 to 10 $String = "" For $j = 0 to $len-1 $String &= mod($i+$j,10) Next ConsoleWrite($String&@CRLF) $i = mod($i+1,10) Next Edited November 15, 2018 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
iamtheky Posted November 16, 2018 Share Posted November 16, 2018 That shit is so clever @mikell, I even gave it time and looked again, still awesome. That should be the help file example for srer. ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
KickStarter15 Posted November 16, 2018 Author Share Posted November 16, 2018 @mikell and @Nine, awesome guys, never thought that there are many ways to have the result the same. Yup clever one mikell, making it more interesting by using regex. Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. 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