[Gambas-user] RE: Counting Textboxes

Pablo Vera pvera at ...729...
Mon Dec 20 19:20:01 CET 2004


After digging through the online manual, I came up with "the solution", 
replace the code for CountTextboxes as follows:

PUBLIC FUNCTION CountTextboxes() AS Integer
DIM ctl AS Control
DIM Count AS Integer
  Count = 0
  FOR EACH ctl IN ME.Children
    IF Object.Class(ctl) = "TextBox" THEN Count = Count + 1
  NEXT
  RETURN Count
END

The Object.Class() method returns the name of the class for the object.


Saludos,
Pablo Vera



P at ...727...@N wrote:

>Thank you Pablo,
>I have been doing that all this time.
>
>Since I want to use the tag property for another purpose,
>now I'm looking another better or proper approach, if there are any.
>I like my program to know the type of each control in the form using the
>"type" of the control.
>
>I tried this :
>----------------------------------------
>Dim Kontrol as Control
>
>For Each Kontrol in fmOne.Children
>  Message(Str(TypeOf(Kontrol)))
>Next
>----------------------------------------
>It always return 16 whether the control is button, textbox, or else.
>I guess 16 is TypeOf "Control" itself eh?
>
>Anybody has another way? Please?
>Thx anyone
>
>salam
>-iggy
>
>  
>
>>Date: Thu, 16 Dec 2004 08:08:46 -0600
>>From: Pablo Vera <pvera at ...729...>
>>Organization: VERCAN Consultores, SA de CV
>>To:  gambas-user at lists.sourceforge.net
>>Subject: Re: [Gambas-user] need help : form control (another one)
>>Reply-To: gambas-user at lists.sourceforge.net
>>
>>You could add a PUBLIC FUNCTION to fmOne that returns the number of
>>textboxes.  For this to work, you need to use the TAG property of each
>>control to identify it.  Every time you create a Textbox, you need to
>>assign the string "textbox" to its TAG property.
>>
>>
>>In fmOne:
>>
>>PUBLIC FUNCTION CountTextboxes() AS Integer
>>DIM ctl AS Control
>>DIM Count AS Integer
>>  Count = 0
>>  FOR EACH ctl IN ME.Children
>>    IF ctl.TAG = "textbox" THEN Count = Count + 1
>>  NEXT
>>  RETURN Count
>>END
>>
>>
>>In fmMain:
>>
>>PUBLIC SUB btnGo_Click()
>>  txtCount.Text = fmOne.CountTextboxes
>>END
>>
>>
>>I hope this helps.
>>
>>Saludos,
>>Pablo Vera
>>
>>
>>
>>Iggy Budiman wrote:
>>
>>    
>>
>>>Hi all,
>>>I have another question about form controls.
>>>
>>>2 forms (fmMain and fmOne)
>>>fmMain has 1 textbox (txtCount) and 1 button (btnGo)
>>>fmOne has many controls, several labels, buttons and textboxes.
>>>
>>>What I want to do is :
>>>When I click btnGo @fmMain, txtCount @fmMain display the number
>>>      
>>>
>>of textboxes
>>    
>>
>>>at fmOne
>>>
>>>Thanks b4
>>>
>>>little info for Benoit : In my country, Gambas is local
>>>      
>>>
>>vegetable (cucumber
>>    
>>
>>>family)
>>>When I talk to people about your Gambas, everybody always
>>>      
>>>
>>listened with big
>>    
>>
>>>smile.
>>>      
>>>
>
>
>
>
>-------------------------------------------------------
>SF email is sponsored by - The IT Product Guide
>Read honest & candid reviews on hundreds of IT Products from real users.
>Discover which products truly live up to the hype. Start reading now. 
>http://productguide.itmanagersjournal.com/
>_______________________________________________
>Gambas-user mailing list
>Gambas-user at lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>
>
>
>  
>


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.296 / Virus Database: 265.6.1 - Release Date: 12/20/04





More information about the User mailing list