Jump to content

count fields that contain string


Queener
 Share

Recommended Posts

I have 14 fields and I was wondering is there an easier way to count the fields that contain Child?

If guictrlread($textbox1) = "Child" then
$xcountchild = $xcountchild + 1
endif

etc...

So those are my current codes, but is there an easier way to could?

Edited by Queener

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")
Link to comment
Share on other sites

How do you set this variables?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

$textbox1, $textbox2, etc... for textboxes

$xcountchild is to call all variables that the textboxes contain the string child.

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")
Link to comment
Share on other sites

I mean: Do they get set using a GUI?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

yes. I also fixed my code during reading the textbox lol

 

I tried, but it's not working because I would think I needed to declare it as an object.

 

$x = 0
    
    For $x = 0 To 14
      If guictrlread($InputName($x)) = "Child" Then
        $xchild = $xchild + $x
        
      EndIf
    Next
    MsgBox(0, "", $xchild)

 

Edited by Queener

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")
Link to comment
Share on other sites

Assign the IDs returned from GUICtrlCreate* to an array and then loop thorugh this array doing a GUICtrlRead one each ID.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Queener,

See if this makes sense...

#include <StaticConstants.au3>
#include <GuiConstantsEx.au3>

Local $gui010 = GUICreate('Find ""Child""',200,500)

Local $inputname[14]

For $1 = 0 To 13
    $inputname[$1] = GUICtrlCreateLabel('', 10, $1 * 30 + 10, 90, 20, $SS_SUNKEN)
Next

For $1 = 0 To Random(0, UBound($inputname) - 1, 1)
    GUICtrlSetData($inputname[$1], 'Child')
Next

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $gui_event_close
            ExitLoop
    EndSwitch
WEnd

Local $xchild

For $x = 0 To 13
    If GUICtrlRead($inputname[$x]) = "Child" Then ; <--- you were using $inputname as a function, use it as an array
        $xchild += 1
    EndIf
Next
MsgBox(0, "", $xchild)

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

Wow, exactly what I'm looking for... My 60 lines became less than 12 lines. LoL

 

Thanks for the help. Much appreciated.

 

 

Edited by Queener

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")
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...