0

Hi ,,,

I need your help plz...

i have programed a calculator and i have an On\Of button .

when the user click On\Off button i want to disable all buttons i have except On\Of button, But also I need to enable all buttons when the user click it again.

and i do not want to use any decision constructs.

i need ur help as soon as possible plz ..


i am beginner in VB

Thank you

3
Contributors
9
Replies
10
Views
6 Years
Discussion Span
Last Post by prvnkmr194
0

If I am understanding correctly, this might help you.

Disables a Button:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button2.Enabled = false
    End Sub

Enables a button:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button2.Enabled = True
    End Sub

If not let me know. :)

-1

thank you for fast replaying ..

i think i will need to make my question clear .

Private Sub btnOnOF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOnOF.Click
        btnAddition.Enabled = False
        btnDivision.Enabled = False
        btnEq.Enabled = False
        btnSubtruction.Enabled = False
        btnMod.Enabled = False
        btnSqrRoot.Enabled = False
        btnMultiplication.Enabled = False
        btnMRec.Enabled = False
        btnMSt.Enabled = False
        txtFstNum.Enabled = False
        txtOutput.Enabled = False
        txtSecNum.Enabled = False

    End Sub

at this moment i have disable all the buttons except On\Of button ..

and now i need to enable them when the user click on On\of button...

what i should do ..

0

What I think you might need is an Enable_Change Event. I will try and put something together and try to help you if no one beats me to it.
:)

0
Dim flag as boolean=False
Private Sub btnOnOF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOnOF.Click
if flag=Flase then
        btnAddition.Enabled = False
        btnDivision.Enabled = False
        btnEq.Enabled = False
        btnSubtruction.Enabled = False
        btnMod.Enabled = False
        btnSqrRoot.Enabled = False
        btnMultiplication.Enabled = False
        btnMRec.Enabled = False
        btnMSt.Enabled = False
        txtFstNum.Enabled = False
        txtOutput.Enabled = False
        txtSecNum.Enabled = False
flag=True
else
        btnAddition.Enabled = True
        btnDivision.Enabled = True
        btnEq.Enabled = True
        btnSubtruction.Enabled = True
        btnMod.Enabled = True
        btnSqrRoot.Enabled = True
        btnMultiplication.Enabled = True
        btnMRec.Enabled = True
        btnMSt.Enabled = True
        txtFstNum.Enabled = True
        txtOutput.Enabled = True
        txtSecNum.Enabled = True
flag=True
end if
    End Sub

I hope it will help you

0

Thank you for replaying ,,,


But, i want to solve this question without using any decision constructs

Thank you

1
Dim flag As Boolean = False

Private Sub btnOnOF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOnOF.Click
        btnAddition.Enabled = flag
        btnDivision.Enabled = flag
        btnEq.Enabled = flag
        btnSubtruction.Enabled = flag
        btnMod.Enabled = flag
        btnSqrRoot.Enabled = flag
        btnMultiplication.Enabled = flag
        btnMRec.Enabled = flag
        btnMSt.Enabled = flag
        txtFstNum.Enabled = flag
        txtOutput.Enabled = flag
        txtSecNum.Enabled = flag
        flag = Not flag
    End Sub

I this you want.........I think so

Edited by prvnkmr194: n/a

Votes + Comments
Thank you
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.