Jump to content

[Solved] Add +1 in each number


Recommended Posts

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.:sweating: I have my example below:

Input number is 123  range is  from 0-9.

Results:

123
234
345
456
567
678
789
890
901
012
123

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 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

#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 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

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)

 

Link to comment
Share on other sites

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^_^

image.png.d03329acc37937b66e48476b8f3a083a.png

 

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

Abit late but with another version... 

#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 by Skeletor

Kind Regards
Skeletor

"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

9 minutes ago, Deye said:

must have misread :construction:, Oops :muttley: Again 

Yeah, I also did that many times as well.:muttley::sweating:. Late to realized:lol:

 

@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.:D

 

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

#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

 

2018-11-15_21-20-05.png

Link to comment
Share on other sites

... and regex version of Malkey's code   :idiot:

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)

 

Link to comment
Share on other sites

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

:lol:

Edited by Nine
Link to comment
Share on other sites

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

@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.B)

 

 

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...