CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2001
    Posts
    65

    How can you do this?

    Hi,

    I have a button. When I press that button, 2 more buttons appear :

    Button2.Visible = True
    Button3.Visible = True.

    But, when I press the main button again, they don`t go away, they stay there.

    What is the code, so that when the main button is clicked the next time, the other 2 buttons disappear again?

    Thanks

    Mark


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: How can you do this?

    Define the boolean var on the form level
    dim bBool as boolean

    on Button1_Click evnt

    if Not bBool then
    Button2.Visible = True
    Button3.Visible = True.
    else
    Button2.Visible = False
    Button3.Visible = False
    end if
    bBool = Not bBool




    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: How can you do this?

    Or even:

    private Sub Button1_Click()

    Button2.Visible = Not Button2.Visible
    Button3.Visible = Button2.Visible

    End Sub




    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  4. #4
    Join Date
    Jun 2001
    Location
    Haryana,India
    Posts
    8

    Re: How can you do this?

    Dear Jones

    Your Answer of making visible false is Impressive but I think there is one
    mistake you forgot to put "Not" in your statement Otherwise liked your answer.


    private sub Command1_Click()
    Command2.visible = Not Command2.visible
    Command3.visible = Not Command3.visible
    End Sub





    Deepak Adlakha.



  5. #5
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: How can you do this?

    No - on the second line, I have:

    Button3.Visible = Button2.Visible




    Which ensures that no matter what happens, both buttons are either visible or hidden. In your example if one were hidden and the other visible then clicking button1 would swap them over.

    Hope this helps,
    Duncan


    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  6. #6
    Join Date
    Aug 2001
    Location
    Alberta, Canada
    Posts
    10

    Re: How can you do this?

    You also could use:

    If button2.visible = true then
    button2.visible = false
    button3.visible = false
    else
    button2.visible = true
    button3.visible = true
    end if





  7. #7
    Join Date
    Aug 2001
    Location
    India
    Posts
    173

    Re: How can you do this?

    Private Sub command1_Click()
    command2.visible = not command2.visible
    command3.visible = not command3.visible
    End Sub


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured