CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    15

    Command button Reuse

    I have a form with a command button named 'Compute'.After the user clicked to compute and the results generated,I set certain properties on my output text box (Locked=True and ForeColor=vbYellow)and my Compute button caption to change to 'Try again'

    I would like to use the SAME button to do another computation.I wish to toggle the properties on the text box which I've just changed and the button to read as 'Compute' again.

    Do you think this is possible ? Pls enlighten me.

    Lots of thanks.


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Command button Reuse

    This should work

    sub compute_click
    select case compute.caption
    case "Compute"
    ' do your computation
    txt.Locked = true
    txt.ForeColor = vbYellow
    compute.caption = "Try Again"
    case "Try Again"
    compute.caption = "Compute"
    ' do your computation
    txt.Locked = false
    txt.ForeColor = ???
    end select
    end sub





  3. #3
    Join Date
    Jan 2000
    Location
    Saskatchewan, Canada
    Posts
    595

    Re: Command button Reuse

    If you don't mind using two command buttons, you can place both of them in the same position and toggle the visible property.


    private sub cmd1_click()
    cmd2.visible = true
    cmd1.visible = false
    end sub

    private sub cmd2_click()
    cmd1.visible = true
    cmd2.visible = false
    end sub




    David Paulson

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