Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Another textbox 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!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Another textbox question

I would use a TextBox_Change event to catch changes in the textboxes,
and then check if both textboxes has a valid text:

Private Sub TextBox1_Change()
If Me.TextBox1.Value = "Valid" And Me.TextBox2.Value = "Text" Then
Me.CommandButton1.Enabled = True
Else
Me.CommandButton1.Enabled = False
End If
End Sub

Private Sub TextBox2_Change()
If Me.TextBox1.Value = "Valid" And Me.TextBox2.Value = "Text" Then
Me.CommandButton1.Enabled = True
Else
Me.CommandButton1.Enabled = False
End If
End Sub

Regards,
Per

On 30 Dec., 21:29, "Robert Crandal" wrote:
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!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Another textbox question

Put another way...

================================================== ==========
Me.CommandButton1.Enabled = _
(Me.TextBox1.Value = "Valid" And Me.TextBox2.Value = "Text")
================================================== ==========

Per Jessen expressed precisely :
I would use a TextBox_Change event to catch changes in the textboxes,
and then check if both textboxes has a valid text:

Private Sub TextBox1_Change()
If Me.TextBox1.Value = "Valid" And Me.TextBox2.Value = "Text" Then
Me.CommandButton1.Enabled = True
Else
Me.CommandButton1.Enabled = False
End If
End Sub

Private Sub TextBox2_Change()
If Me.TextBox1.Value = "Valid" And Me.TextBox2.Value = "Text" Then
Me.CommandButton1.Enabled = True
Else
Me.CommandButton1.Enabled = False
End If
End Sub

Regards,
Per

On 30 Dec., 21:29, "Robert Crandal" wrote:
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!


--
Garry

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


  #4   Report Post  
Posted to microsoft.public.excel.programming
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
TextBox question Patrick Simonds Excel Programming 2 July 7th 06 08:32 AM
Textbox question Vince Excel Programming 3 June 22nd 05 11:01 PM
Textbox question? Greg B Excel Discussion (Misc queries) 2 June 2nd 05 03:56 PM
Textbox question Jorge Rodrigues[_2_] Excel Programming 4 November 13th 04 11:08 PM
textbox question dok112[_22_] Excel Programming 1 August 10th 04 07:54 AM


All times are GMT +1. The time now is 08:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"