Results 1 to 9 of 9

Thread: [RESOLVED] One click selection

Hybrid View

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    39

    Resolved [RESOLVED] One click selection

    For 2 command bottons in a form, let's say "yes" or "no", how to make it as a single switch selection, so that it chooses "yes" or "no" alternatively and I can just make a single click to comfirm the selection?

    Thanks for answering.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: One click selection

    You can have two option buttons (say optYes and optNo) and check which one is selected:
    VB Code:
    1. Private Sub Command1_Click()
    2.     Select Case True
    3.         optYes.Value
    4.             'do something
    5.         optNo.Value 'OR use Case Else (if you only have 2 options)
    6.             'do something else
    7.     End Select
    8. End Sub

  3. #3
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: One click selection

    ..or you could use 2 option buttons with Graphical style. They will look just like a command button.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    39

    Re: One click selection

    Sorry for I did not make my question clear.

    For the 2 buttons, I want them to be something like flashing alternatively, maybe 1 sec interval, "yes" is highlighted when "no" is normal and vice versa.

    For selection, I want the selection only depends on a single click, no matter where the cursor is, so command1_click may not be useful.

  5. #5
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: One click selection

    To have the slection with just one click, you need grouped controls (just like option button, whre either one can be selected, but not both).
    For for "flashing" stuff, you need some timer-stuff the change the the presentation, but I'm not sure what you really want to show.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  6. #6

  7. #7

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    39

    Re: One click selection

    Quote Originally Posted by opus
    To have the slection with just one click, you need grouped controls (just like option button, whre either one can be selected, but not both).
    Sorry I cannot get your meaning since I am still a learner of programming, can you give more details on this?

    Quote Originally Posted by opus
    For for "flashing" stuff, you need some timer-stuff the change the the presentation, but I'm not sure what you really want to show.
    I want to present it with changing the backcolor of button, with timer to control the frequency. Stuff like Command1.BackColor = &H8000000D

  8. #8
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: One click selection

    try this, add 2 command buttons and 1 timer:
    VB Code:
    1. Private Sub Form_Load()
    2.     Command1.Caption = "Yes"
    3.     Command2.Caption = "No"
    4.     Command1.BackColor = vbGreen
    5.     Timer1.Interval = 1000
    6.     Timer1.Enabled = True
    7. End Sub
    8.  
    9. Private Sub Timer1_Timer()
    10.     If Command1.BackColor = vbGreen Then
    11.         Command2.Enabled = True
    12.         Command2.BackColor = vbRed
    13.         Command1.BackColor = vbNormal
    14.         Command1.Enabled = False
    15.     Else
    16.         Command1.Enabled = True
    17.         Command2.Enabled = False
    18.         Command1.BackColor = vbGreen
    19.         Command2.BackColor = vbNormal
    20.     End If
    21. End Sub
    Harsh
    Show Appreciation. Rate Posts.

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