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
Re: enable and disabled buttons
Never mind I figured it out. Thank you
Re: enable and disabled buttons
The simplest solution
vb Code:
Private Sub Text1_Change()
Command1.Enabled = Not (Text1.Text = vbNullString)
End Sub
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.
Re: enable and disabled buttons
for check box use
vb Code:
Private Sub Check1_Click()
Command1.Enabled = Not (Check1.Value = 0)
End Sub
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
Re: enable and disabled buttons
Quote:
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
Re: enable and disabled buttons
Thank you 4x2y, I greatly appreciate it. It works perfectly
Re: enable and disabled buttons
is this more games for learning stuff?
Re: enable and disabled buttons
Quote:
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.
Re: enable and disabled buttons
for what purpose a limited set of words like flash cards or any word that the user chooses?
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
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.
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?
Re: enable and disabled buttons
Quote:
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.