Results 1 to 3 of 3

Thread: option button

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2001
    Location
    Netherlands
    Posts
    1

    Question option button

    Hello,

    In the click-event of the option buttons i have some code that add the caption of the option button in a listbox when value is true.

    When a user changes this value while using the program i use a piece of code that puts all of the option buttons in the program to default when running a new session of the program.

    And this give the problem. Every time i use the "set to default" code it puts the caption of the option button to the listbox.

    And this is not what i want...


    HELP....


    Greetings,
    Progger

  2. #2
    Fanatic Member rudvs2's Avatar
    Join Date
    Mar 2001
    Location
    NZ
    Posts
    935
    An easy way to do this would be something along these lines

    in the Option buttons click event.

    VB Code:
    1. 'In General Declarations section of the Form
    2. Public isDefault As Boolean
    3.  
    4.  
    5. Private Sub Option1_Click()
    6.  
    7. If Option1.Value = True then
    8.       If isDefault = False Then
    9.               List1.Additem Option1.Caption
    10.       Else
    11.               isDefault = False
    12.       End If
    13. End If
    14.  
    15. End Sub

    Just set the isDefault value to false when for all events except when you run your makedefault code set the isDefault value to true in there

  3. #3
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    Hi
    A generic way to accomplish this in the minimum of code and so that ur program maintenance doesnt become a nightmare is to set a flag before combos, checkboxes, option boxes etc are loaded and then reset the flag after all items are loaded.

    pseudo code
    Dim fbooDoStuff as boolean 'I dont really name vars this way!!

    fbooDoStuff = False 'defaults to false anyhow
    'Code to set your option boxes to default settings
    fbooDoStuff = True

    In any of ur option box, combo box etc Click events (or whichever one fires dep on the control) just test the do stuff variable

    If fbooDoStuff then
    'Process as if the user selected
    End If

    Regards
    Stuart
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

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