View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
GS[_5_] GS[_5_] is offline
external usenet poster
 
Posts: 226
Default Another textbox question

Robert Crandal formulated the question :
My userform has 2 textboxes and on push button.
The pushbutton is initially disabled or grayed out.

I would like the pushbutton to become enabled
once BOTH textboxes have been filled in with any
valid text strings. Also, if the user types data into
both textboxes, but then deletes the text, I would
like to once again disable the pushbutton.

So, in other words, the push button should only be
enabled on the condition that valid text is in both
textboxes.

What is a good way to code this?

Thank you!


I was thinking that your validation should control a boolean variable
(module level in the userform) that only gets set to TRUE when all data
inputs are valid. Use this setting to control the button.

Example:
Public bAllDataValid As Boolean 'make it accessible to any code...

<In the Change event for each textbox
CommandButton1.Enabled = bAllDataValid

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc