|
-
Feb 13th, 2012, 02:34 AM
#1
Thread Starter
Member
enable and disabled buttons
When I start my program, a button is disabled because i wrote if my text box is empty its disabled. But if the value of the text box is filled then the button will automatically enable. When i delete the value completely in the text box, the button is still enabled. How do i keep it so as long as the value of the text box is empty the button is disabled, even after i have deleted the value? Thank You. Here is my code.
Private Sub Form_Load()
Command1.Enabled = False
Command2.Visible = False
End Sub
Private Sub Text1_Change()
If Text1.Text > "" Then
Command1.Enabled = True
End If
End Sub
-
Feb 13th, 2012, 02:45 AM
#2
Thread Starter
Member
Re: enable and disabled buttons
Never mind I figured it out. Thank you
-
Feb 13th, 2012, 03:22 AM
#3
Re: enable and disabled buttons
The simplest solution
vb Code:
Private Sub Text1_Change() Command1.Enabled = Not (Text1.Text = vbNullString) End Sub
-
Feb 13th, 2012, 04:27 AM
#4
Lively Member
Re: enable and disabled buttons
if there are more controls on form like text boxes, check boxes then how to enable and disable the button in the same manner.
-
Feb 13th, 2012, 04:31 AM
#5
Re: enable and disabled buttons
for check box use
vb Code:
Private Sub Check1_Click() Command1.Enabled = Not (Check1.Value = 0) End Sub
-
Feb 13th, 2012, 04:39 AM
#6
Thread Starter
Member
Re: enable and disabled buttons
I am making a translation program. When the user types in a word in the first text box, then clicks translate the translated word appears in the second text box. But I don't want it to be case sensitive.
Here is my code:
Private Sub Command3_Click()
If Text1.Text = "Hello" Then
Text2.Text = "Hola"
End If
-
Feb 13th, 2012, 04:49 AM
#7
Re: enable and disabled buttons
 Originally Posted by mcampos0809
I am making a translation program. When the user types in a word in the first text box, then clicks translate the translated word appears in the second text box. But I don't want it to be case sensitive
You can use LCase function
vb Code:
Private Sub Command3_Click()
If LCase$(Text1.Text) = "hello" Then
Text2.Text = "Hola"
End If
End Sub
You can also add Option Compare Text at the top of your form code, by adding that line, all string comparation will not be case sensitive, so you can use your code as it is
vb Code:
Option Compare Text
Private Sub Command3_Click()
If Text1.Text = "Hello" Then
Text2.Text = "Hola"
End If
End Sub
-
Feb 13th, 2012, 05:10 AM
#8
Thread Starter
Member
Re: enable and disabled buttons
Thank you 4x2y, I greatly appreciate it. It works perfectly
-
Feb 13th, 2012, 02:13 PM
#9
Frenzied Member
Re: enable and disabled buttons
is this more games for learning stuff?
-
Feb 13th, 2012, 02:15 PM
#10
Thread Starter
Member
Re: enable and disabled buttons
 Originally Posted by incidentals
is this more games for learning stuff?
I'm writing a translation program. simply type in the first text box a word in English, click translate, and the translated word will appear in the second text box.
-
Feb 13th, 2012, 03:08 PM
#11
Frenzied Member
Re: enable and disabled buttons
for what purpose a limited set of words like flash cards or any word that the user chooses?
-
Feb 13th, 2012, 03:35 PM
#12
Thread Starter
Member
Re: enable and disabled buttons
right now just vocabulary words. like if the user types "walk" in the first text box, and clicks translate "caminar" appears on the second text box. But if you type "I walk to the park", and click translate
nothing happeneds
-
Feb 15th, 2012, 05:19 AM
#13
Lively Member
Re: enable and disabled buttons
if there are lot of more controls on form like text boxes, check boxes then
how to enable and disable the button in the same manner. note that that should not perform one by one. any function.
-
Feb 15th, 2012, 07:46 AM
#14
Re: enable and disabled buttons
It would have to perform one by one (or at least in groups) because different controls have different syntax for determining use.
Textboxs have a text property that can be checked....checkboxs have no text property...they use a Value property
How many controls do you have on this form?
-
Feb 15th, 2012, 07:53 AM
#15
Re: enable and disabled buttons
 Originally Posted by yasrab
if there are lot of more controls on form like text boxes, check boxes then
how to enable and disable the button in the same manner. note that that should not perform one by one. any function.
The best solution for this is creating a control array, by this way you can use
vb Code:
Private Sub Check1_Click(Index As Integer)
Command1.Enabled = Not (Check1.Item(Index).Value = 0)
End Sub
If you have 100 checkbox, above line is what you need to enable/disable command1 when any value of them changed.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|