Sign in to follow this  
Followers 0
damod

Help!! GUICtrlRead Multiple inputboxes

12 posts in this topic

thanks in advance for the help.. I am trying to read from multiple input boxes using a loop. I cannot seem to pull it off and cant figure out what i am doing wrong.

Any help would be great. Thanks again

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 405, 279, 302, 218)
$Input1 = GUICtrlCreateInput("Input1", 48, 40, 121, 21)
$Input2 = GUICtrlCreateInput("Input2", 72, 104, 121, 21)
$Input3 = GUICtrlCreateInput("Input3", 200, 176, 121, 21)
$Input4 = GUICtrlCreateInput("Input4", 336, 248, 121, 21)
$Button1 = GUICtrlCreateButton("Button1", 56, 216, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            For $i = 1 to 3
                MsgBox(0,"test",$i)           ; display current value in $i
                $test = "$Input" & $i         ; fill $test with text "$Input" and value of $i should result in $Input1 and so on
                MsgBox(0,"test",$test)        ; display value of $test1 - should display $Input1
                $test1 = GUICtrlRead($test)   ; read from $test 
                MsgBox(0,"test",$test1)       ; display the results of read
                $test2 = GUICtrlRead($Input1) ; read the sam again 
                MsgBox(0,"test2",$test2)      ; display the read
            Next

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Are you looking for something like this?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>

#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 405, 279, 302, 218)
$Input1 = GUICtrlCreateInput("Input1", 48, 40, 121, 21)
$Input2 = GUICtrlCreateInput("Input2", 72, 104, 121, 21)
$Input3 = GUICtrlCreateInput("Input3", 200, 176, 121, 21)
$Input4 = GUICtrlCreateInput("Input4", 336, 248, 121, 21)
$Button1 = GUICtrlCreateButton("Button1", 56, 216, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            MsgBox(0, "Input1", GUICtrlRead($Input1))
            MsgBox(0, "Input2", GUICtrlRead($Input2))
            MsgBox(0, "Input3", GUICtrlRead($Input3))
            MsgBox(0, "Input4", GUICtrlRead($Input4))
    EndSwitch
WEnd
Edited by Herb191

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Or with a For..Next Loop try this.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>

#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 405, 279, 302, 218)
$Input1 = GUICtrlCreateInput("Input1", 48, 40, 121, 21)
$Input2 = GUICtrlCreateInput("Input2", 72, 104, 121, 21)
$Input3 = GUICtrlCreateInput("Input3", 200, 176, 121, 21)
$Input4 = GUICtrlCreateInput("Input4", 336, 248, 121, 21)
$Button1 = GUICtrlCreateButton("Button1", 56, 216, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            For $A = $Input1 To $Input4
                MsgBox(0, "Inputs", GUICtrlRead($A))
            Next
    EndSwitch
WEnd

I personally would create an Array e.g. $Input[5] = [4] and then $Input[1] = GUICtrlCreateInput("... then loop through the Array.

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Yes and no.... I only posted a small example of the code... There are over 30 input boxes on the real gui. I don't want to write code for each. I would rather process them in a loop, but I cannot figure out how to get it to work. this might clear it up a bit

For $i = 1 to 3
MsgBox(0,"test","$Input" & $i)
                ;$read = GUICtrlRead("$Input" & $i)
                MsgBox(0,"test",GUICtrlRead("$Input" & $i))
                MsgBox(0,"test",GUICtrlRead($Input1))
                
                                
                
Next

Share this post


Link to post
Share on other sites

sorry all... my computer decide freak out and post before I was done... I will read the above comments before completing the post

Share this post


Link to post
Share on other sites

You guys are fantastic.. This is working great... Thanks so much for the help

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

A good example for your "Function Folder" if you want to loop the creation of buttons and find which one was clicked on >>

I updated the Function

It uses GUICtrlCreateDummy() which is sometimes an under appreciated Function within AutoIt.

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Whoops! I amended the version by taking out the Array!

#include <GUIConstantsEx.au3>

$x = 0
$Gui = GUICreate("Test", 125, 34 )

$Btn_Start = GUICtrlCreateDummy()
For $i = 1 To 5
    $x = ($i - 1) * 25
    GUICtrlCreateButton($i, $x, 5, 24, 24)
Next
$Btn_End = GUICtrlCreateDummy()

GUISetState(@SW_SHOW)

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Btn_Start To $Btn_End
            For $i = $Btn_Start To $Btn_End
                If $Msg == $i Then
                    MsgBox(0, "test", "Button: " & GUICtrlRead($i))
                EndIf
            Next
    EndSwitch
    Sleep( 10)
WEnd

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I was playing with the code change posted by Deathbringer

(using eval) - I am confused about one thing.... If I use the following code what does the value

displayed in line 24 represent - MsgBox(0,"eval result",$test) ?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 405, 279, 302, 218)
$Input1 = GUICtrlCreateInput("Input1", 48, 40, 121, 21)
$Input2 = GUICtrlCreateInput("Input2", 72, 104, 121, 21)
$Input3 = GUICtrlCreateInput("Input3", 200, 176, 121, 21)
$Input4 = GUICtrlCreateInput("Input4", 336, 248, 121, 21)
$Button1 = GUICtrlCreateButton("Button1", 56, 216, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            For $i = 1 to 3
                MsgBox(0,"$i",$i)           ; display current value in $i
                $test = Eval("Input" & $i)         ; fill $test with text "$Input" and value of $i should result in $Input1 and so on
                MsgBox(0,"eval result",$test)        ; display value of $test1 - should display $Input1
                $test1 = GUICtrlRead($test)   ; read from $test
                MsgBox(0,"read of input - using eval result",$test1)       ; display the results of read
                $test2 = GUICtrlRead($Input1) ; read the sam again
                MsgBox(0,"Read of Input1 using $Input1",$test2)      ; display the read
            Next
    EndSwitch
WEnd
Edited by damod

Share this post


Link to post
Share on other sites

I am posting more of the code... I cannot figure out how to do this. I will post this in two sections first the part of the code that I can't figure out and then the entire script. I am trying to use eval in a loop to fill in the following line -

$IPOctets = StringSplit(GUICtrlRead($ReadEval), ".") ; split the input field using the "." character

I have tried every combonation i can think of to get this to work but never get the result i expect. If i replace $ReadEval with $Input1 it works great.

Thanks again for the help

$count = ""
                    For $v = $Input1 to $Input4     ;loop count input boxes with values 
                        
                        $Value = GUICtrlRead($v)
                        
                        If  $Value <> "" Then 
                            $count = $count + 1
                            
                        EndIf
                        
                    Next
                    
                    MsgBox(0,"Count","Total count of input boxes with values " & $count)
                
                    For $q= 1 to $count ; Loop based on number of input boxes with values - must be in order left down
                        
                        MsgBox(0,"$q","Current Value in $q = " & $q)
                        $Eval = Eval("$Input" & $q)
                        MsgBox(0,"$Eval","Eval of $Input and $q = " & $Eval)
                        $ReadEval = GUICtrlRead($Eval)                      
                        $IPOctets = StringSplit(GUICtrlRead($ReadEval), ".") ; split the input field using the "." character
                        MsgBox(0,"$IPOctets","Current Value in $IPOctets = " & $IPOctets)
                        If $IPOctets[0] <> 4 Then  ; test for number of octets
                            MsgBox(0, "Entries insufficient", "Please enter four octets")
                            ExitLoop
                        EndIf
                        For $i = 1 To 4 ; check all four octets
                            If StringIsDigit($IPOctets[$i]) = 0 Then ; test that entries are digits
                                MsgBox(0, "NAN", "Position " & $i & " is not a number.")
                                ExitLoop(2)
                            EndIf
                
                            If $IPOctets[$i] <0 Or $IPOctets[$i] > 255 Then ; test that digits are within valid range
                                MsgBox(0, "Out of bounds", "Enter a number from 0 to 255 in position " & $i)
                                ExitLoop(2)
                            EndIf
                
                        Next
                        
                    Next

Complete Script

#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
;Global $Input1, $Input2, $Input3
#Region ### START Koda GUI section ### Form=c:\users\superdamod\desktop\vobhelper\vobhelper.kxf
$Form1_1 = GUICreate("Form1", 618, 448, 200, 133)
$Button1 = GUICtrlCreateButton("GO", 80, 400, 75, 25)
$Button2 = GUICtrlCreateButton("Help", 264, 400, 75, 25)
$Button3 = GUICtrlCreateButton("Exit", 448, 400, 75, 25)
$Tab1 = GUICtrlCreateTab(0, 0, 617, 393)
$TabSheet1 = GUICtrlCreateTabItem("Tab1")
$Pic1 = GUICtrlCreatePic("turbine.bmp", 24, 104, 265, 273)
$Pic2 = GUICtrlCreatePic("Logo_Vestas.bmp", 120, 32, 377, 97)
$Label1 = GUICtrlCreateLabel("VOB Multiple Park View", 312, 192, 225, 28)
GUICtrlSetFont(-1, 14, 800, 4, "MS Sans Serif")
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$Combo1 = GUICtrlCreateCombo("Combo1", 32, 264, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo2 = GUICtrlCreateCombo("Combo2", 32, 320, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo3 = GUICtrlCreateCombo("Combo3", 229, 320, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo4 = GUICtrlCreateCombo("Combo4", 229, 264, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo5 = GUICtrlCreateCombo("Combo5", 424, 264, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo6 = GUICtrlCreateCombo("Combo6", 424, 320, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo7 = GUICtrlCreateCombo("Combo7", 416, 160, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Label2 = GUICtrlCreateLabel("Select Your Current Screen Resolution ", 208, 168, 189, 17)
$Checkbox1 = GUICtrlCreateCheckbox("Check This Box To Save Your Current Selections As Default", 32, 224, 305, 17)
$Pic3 = GUICtrlCreatePic("ogo_Vestas.bmp", 120, 32, 377, 97)
$TabSheet3 = GUICtrlCreateTabItem("TabSheet3")
$Pic4 = GUICtrlCreatePic("Logo_Vestas.bmp", 232, 24, 377, 97)
$Group1 = GUICtrlCreateGroup("Server Group 1", 11, 120, 177, 257)
$Input1 = GUICtrlCreateInput("10.106.3.220", 38, 160, 121, 21)
$Input2 = GUICtrlCreateInput("", 38, 195, 121, 21)
$Input3 = GUICtrlCreateInput("", 38, 230, 121, 21)
$Input4 = GUICtrlCreateInput("", 38, 265, 121, 21)
$Input5 = GUICtrlCreateInput("", 38, 300, 121, 21)
$Input6 = GUICtrlCreateInput("", 38, 335, 121, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Server Group 2", 220, 120, 177, 257)
$Input7 = GUICtrlCreateInput("", 248, 160, 121, 21)
$Input8 = GUICtrlCreateInput("", 248, 192, 121, 21)
$Input9 = GUICtrlCreateInput("", 248, 230, 121, 21)
$Input10 = GUICtrlCreateInput("", 248, 265, 121, 21)
$Input11 = GUICtrlCreateInput("", 248, 300, 121, 21)
$Input12 = GUICtrlCreateInput("", 248, 335, 121, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Server Group 3", 428, 120, 177, 257)
$Input13 = GUICtrlCreateInput("", 456, 160, 121, 21)
$Input14 = GUICtrlCreateInput("", 456, 195, 121, 21)
$Input15 = GUICtrlCreateInput("", 456, 230, 121, 21)
$Input16 = GUICtrlCreateInput("", 456, 265, 121, 21)
$Input17 = GUICtrlCreateInput("", 456, 300, 121, 21)
$Input18 = GUICtrlCreateInput("", 456, 335, 121, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet4 = GUICtrlCreateTabItem("TabSheet4")
$Pic5 = GUICtrlCreatePic("Logo_Vestas.bmp", 120, 32, 377, 97)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button3
            Exit
        Case $Button1
            Switch GUICtrlRead($Tab1)
                Case 0
                    MsgBox(0,"test","this is tab1")
                Case 1
                    MsgBox(0,"test","this is tab2")
                Case 2
                    
                    $count = ""
                    For $v = $Input1 to $Input4     ;loop count input boxes with values 
                        
                        $Value = GUICtrlRead($v)
                        
                        If  $Value <> "" Then 
                            $count = $count + 1
                            
                        EndIf
                        
                    Next
                    
                    MsgBox(0,"Count","Total count of input boxes with values " & $count)
                
                    For $q= 1 to $count ; Loop based on number of input boxes with values - must be in order left down
                        
                        MsgBox(0,"$q","Current Value in $q = " & $q)
                        $Eval = Eval("$Input" & $q)
                        MsgBox(0,"$Eval","Eval of $Input and $q = " & $Eval)
                        $ReadEval = GUICtrlRead($Eval)                      
                        $IPOctets = StringSplit(GUICtrlRead($ReadEval), ".") ; split the input field using the "." character
                        MsgBox(0,"$IPOctets","Current Value in $IPOctets = " & $IPOctets)
                        If $IPOctets[0] <> 4 Then  ; test for number of octets
                            MsgBox(0, "Entries insufficient", "Please enter four octets")
                            ExitLoop
                        EndIf
                        For $i = 1 To 4 ; check all four octets
                            If StringIsDigit($IPOctets[$i]) = 0 Then ; test that entries are digits
                                MsgBox(0, "NAN", "Position " & $i & " is not a number.")
                                ExitLoop(2)
                            EndIf
                
                            If $IPOctets[$i] <0 Or $IPOctets[$i] > 255 Then ; test that digits are within valid range
                                MsgBox(0, "Out of bounds", "Enter a number from 0 to 255 in position " & $i)
                                ExitLoop(2)
                            EndIf
                
                        Next
                        
                    Next
                    
                Case 3
                    MsgBox(0,"test","this is tab4")
            EndSwitch
                
            
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

@guinness : haha, I like the "boundaries" method, found it pretty clever :x

@damod : remove '$' symbole from line :

$Eval = Eval("$Input" & $q)

should be :

$Eval = Eval("Input" & $q)
Edited by hench

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

I tried that and it did not work.. I tried the following..

$Eval = Eval("Input" & $q)
                        MsgBox(0,"$Eval","Eval of $Input and $q = " & $Eval)
                        $ReadEval = GUICtrlRead($Eval)                      
                        $IPOctets = StringSplit(GUICtrlRead($RealEval), ".") ; split the input field using the "." character
                        MsgBox(0,"$IPOctets","Current Value in $IPOctets = " & $IPOctets)
                        If $IPOctets[0] <> 4 Then  ; test for number of octets
                            MsgBox(0, "Entries insufficient", "Please enter four octets")

and also

MsgBox(0,"$Eval","Eval of $Input and $q = " & $Eval)
                        $ReadEval = GUICtrlRead($Eval)                      
                        $IPOctets = StringSplit(GUICtrlRead($Eval), ".") ; split the input field using the "." character
                        MsgBox(0,"$IPOctets","Current Value in $IPOctets = " & $IPOctets)

Thanks for the help with this

Edited by damod

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