Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enabled a button

Status
Not open for further replies.

olatzcelaya

Programmer
Jan 4, 2008
13
0
0
GB
Hi all,

I am writing a code in Visual Basic to do a program in excel and i want to disabled a button regarding a condition. I have written the following code but it gives me an error in : Button3.Enabled = True. It is like the program is trying to tell me that it is not the correct definition. Could anybody help me in this matter??Any help will be very appreciated.


Private Sub ComboBox5_Click()
Dim e As Integer
If ComboBox5.Text = "YES" Then
e = 0
' The customer decides the type of pallet to use

Button3.Enabled = True

ElseIf ComboBox5.Text = "NO" Then
e = 1
' We decide the type of pallet to use. The cells of pallet width and pallet length are disabled

Button3.Enabled = False
End If
End Sub


THANK YOU ;-),

Olatz
 
What error do you get? AS expected, works fine for me here.

Cheers

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Can't see anything wrong either.

Little addition from here:
The IF gets superfluous if you use such a little implicit logic. Instead of this:
Code:
If ComboBox5.Text = "YES" Then
    e = 0
    ' The customer decides the type of pallet to use
    
    Button3.Enabled = True

ElseIf ComboBox5.Text = "NO" Then
    e = 1
    ' We decide the type of pallet to use. The cells of pallet width and pallet length are disabled
    
    Button3.Enabled = False
End If

You can also write this:
Code:
Button3.Enabled = (ComboBox5.Text = "YES")
e = CInt((ComboBox5.Text = "YES"))+1
The integer value of TRUE is -1, that of FALSE is 0.
So adding 1 to the integer value will return 0 in the case of TRUE and 1 in the case of FALSE.
;-)

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top