Jump to content
Queener

count fields that contain string

Recommended Posts

Queener

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.")

Share this post


Link to post
Share on other sites
water

How do you set this variables?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Queener

$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.")

Share this post


Link to post
Share on other sites
water

I mean: Do they get set using a GUI?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Queener

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.")

Share this post


Link to post
Share on other sites
water

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
kylomas

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

Share this post


Link to post
Share on other sites
Queener

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.")

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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.