Results 1 to 10 of 10

Thread: Visual Basic 6 Buttons

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Posts
    21

    Visual Basic 6 Buttons

    Well I have a question, I have two buttons in the Form; Command1 and Command2. Currently when the appliation starts the user can press both of them as they please.

    Well I dont want that. the thing that I want to do; When the app start the user can ONLY Click on the Command1 button and after the user clicks on Command1 button they shouldn't be able to click on Comman1 again but can click on Command2 this time.

    Any help will be appreciated.

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    control it using

    buttonname.Enabled = True/False
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    Lively Member Cagez's Avatar
    Join Date
    Oct 2002
    Posts
    121
    How about this, I'm a newb but I'll try my best

    VB Code:
    1. ' Code behind Command1 button
    2. Private Sub Command1_Click()
    3.     Command1.Enabled = False
    4.     Command2.Enabled = True
    5. End Sub
    6.  
    7. ' Code behind Command2 button
    8. Private Sub Command2_Click()
    9.     Command1.Enabled = True
    10.     Command2.Enabled = False
    11. End Sub

    And when your making the layout put the Command2 button enabled property to false. That should do it

  4. #4
    Banned Michael_Kamen's Avatar
    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    1,180
    First, set the .Enabled property of command2 to False.
    Then use this code in the click event of Command1
    VB Code:
    1. Command1.Enabled = False
    2. Command2.Enabled = True

  5. #5
    Hyperactive Member Q_Me's Avatar
    Join Date
    Dec 2001
    Posts
    327
    By the time I reply this your question would probly be answered.

    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3. If not Command1.enabled=False Then
    4. Command1.enabled=False
    5. Command2.enabled=True
    6. End If
    7.  
    8. End Sub
    9.  
    10. Private Sub Command2_Click()
    11.  
    12. If not Command2.enabled=False Then
    13. Command2.enabled=False
    14. Command1.enabled=True
    15. End if
    16.  
    17. End Sub
    53323737 15 743 313402 05 740313063. 17 15 4150 743 313402 05 140393403437 5203 743 30210.


  6. #6

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Posts
    21
    thanks a lot.. you guys are really fast I am happy that I found this board
    Last edited by iimrii; Oct 30th, 2002 at 04:28 PM.

  7. #7
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    Disable command1 in the properties window on the right. Set enabled to false over there.
    <removed by admin>

  8. #8
    Banned Michael_Kamen's Avatar
    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    1,180
    Then you should set Command1.Enabled = False at design time:
    Click on command1 and select the enabled property in the property bar. Then set it to false.

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Oct 2002
    Posts
    21
    holly I figured that out by myself I was just gonna edit the post but you guys already posted you guys are realllllyyy fast

    These might be really easy questions for you but I am really new to VB

  10. #10
    Fanatic Member scr0p's Avatar
    Join Date
    Oct 2002
    Location
    VA
    Posts
    720
    You can also do it like this:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4. Command1.Enabled = Not (Command1.Enabled)
    5. Command2.Enabled = Not (Command1.Enabled)
    6. End Sub
    7.  
    8. Private Sub Command2_Click()
    9. Command1.Enabled = Not (Command1.Enabled)
    10. Command2.Enabled = Not (Command1.Enabled)
    11. End Sub
    12.  
    13. Private Sub Form_Load()
    14. Command2.Enabled = False
    15. 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