HelpEnabling OR Disabling A Button

Posts 1–4 of 4 · Page 1 of 1
Enabling OR Disabling A Button
Code:
If (Form2.rbtnAuto.Checked = True) Then
            Me.btnInject.Enabled = False
        ElseIf (Form2.rbtnAuto.Checked = False) Then
            Me.btnInject.Enabled = True
        End If
Das duh code.

it doesn't work.

It should, by all rights, PM me for TV info.
Quote Originally Posted by aeronyx View Post
Code:
If (Form2.rbtnAuto.Checked = True) Then
            Me.btnInject.Enabled = False
        ElseIf (Form2.rbtnAuto.Checked = False) Then
            Me.btnInject.Enabled = True
        End If
Das duh code.

it doesn't work.

It should, by all rights, PM me for TV info.
Im guessing this is for an injector and this is the automatic feature. I would say switch the checkbox to a radiobox. Make one radiobox auto and one manual. It is usually done that way. Now. Yo address the button problem, I would try setting the default to disabled and the auto radiobutton to checked ( or checkbox). Then try it (even without the second part) and see if that works. If it does,.finish off the code with the rest of it. If it doesn't work or I am completly wrong about it being an injector, you can PM me or reply
Quote Originally Posted by StupidFuck View Post
Im guessing this is for an injector and this is the automatic feature. I would say switch the checkbox to a radiobox. Make one radiobox auto and one manual. It is usually done that way. Now. Yo address the button problem, I would try setting the default to disabled and the auto radiobutton to checked ( or checkbox). Then try it (even without the second part) and see if that works. If it does,.finish off the code with the rest of it. If it doesn't work or I am completly wrong about it being an injector, you can PM me or reply
Why change to a radio button? You can't 'deselect' a radio button after you select it, so the only option is to make 2 radio buttons (On/Off), which is a waste of space when a checkbox suits the situation far better.

@aeronyx What exactly is calling this code? I'd recommend putting the following in your rbtnAuto_CheckChanged event:

Code:
Form1.btnInject.Enabled = Not Me.rbtnAuto.Checked
So that the button's state is toggled whenever you toggle the checkbox. I may have got the classes wrong because I'm not sure what you've called them (the fact you had Form2 led me to believe that you have 2 forms; Form1 and Form2.
If (Form2.rbtnAuto.Checked = True) Then
Me.btnInject.Enabled = False
ElseIf (Form2.rbtnManual.Checked = True) Then
Me.btnInject.Enabled = True
End If

but this at a timer
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us