Results 1 to 34 of 34

Thread: [RESOLVED] option button dosnt show the choice when i edit

  1. #1

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Resolved [RESOLVED] option button dosnt show the choice when i edit

    hello every one
    i got a situation

    i added 3 option buttons to my form
    and everything is working ok when i pick one of the 3
    the problem is when i edit the customer to chenge some thing is the option button
    it dosnt show me what i choosed before.(EX if i choose fixed and press the edit button it dosnt show the option button marked)
    this is what i tried to do but no luck.
    If .SubItems(5) = "fixed" Then
    Option1(5).Value = True
    End If
    If .SubItems(6) = "not fixed" Then
    Option2(6).Value = True
    End If
    Option3(7).Value = True

    End With
    tnx in advacend

  2. #2
    Lively Member mikorians's Avatar
    Join Date
    Jun 2010
    Location
    In a fog
    Posts
    83

    Re: option button dosnt show the choice when i edit

    Have you tried the 'control.refresh' function to force an update?
    Be sure you have DoEvents in tight loops to make sure VB6 has time to update the form as well.
    Like OptionN(N).refresh
    You can also use OptionN(index).refresh under the control's click event

  3. #3

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: option button dosnt show the choice when i edit

    Quote Originally Posted by mikorians View Post
    Have you tried the 'control.refresh' function to force an update?
    Be sure you have DoEvents in tight loops to make sure VB6 has time to update the form as well.
    Like OptionN(N).refresh
    You can also use OptionN(index).refresh under the control's click event
    didnt work my friend

  4. #4
    Lively Member mikorians's Avatar
    Join Date
    Jun 2010
    Location
    In a fog
    Posts
    83

    Re: option button dosnt show the choice when i edit

    Perhaps a larger sample of the relevant code

  5. #5
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: option button dosnt show the choice when i edit

    Well depending on how you have your option buttons on your form this line may be keeping it from doing what you want
    Code:
    Option3(7).Value = True
    That line is after the if test so it may be overriding the selection in the if block
    Of course is this option button is in a different container that would not be the case.

    Also you say you added 3 option buttons but what you have shown is 3 option button arrays and it looks as though they have several option buttons in each of them

    For example
    Code:
    Option3(7).Value = True
    Indicates the 8th option button in a control array with at least 8 option buttons in it.
    If you truly are only using 3 and you want them named option 1 - 3 then you should not be using arrays here.

  6. #6

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: option button dosnt show the choice when i edit

    i tried that too didnt work
    and i tried without en array and still didnt work
    i tried option1.value = true
    and so on
    no luck

  7. #7
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: option button dosnt show the choice when i edit

    You say you added 3 option buttons to your form. Are they option1, option2 and option3, or do you have arrays of option buttons (as indicated in your code).
    Or in other words, how many option1 buttons, option2 buttons, and option3 buttons do you have?


    Need a bit more information.... to what does.subItems(x) belong?

  8. #8
    Lively Member mikorians's Avatar
    Join Date
    Jun 2010
    Location
    In a fog
    Posts
    83

    Re: option button dosnt show the choice when i edit

    Here's a simple sample for you I tossed together based on your description...
    Attached Files Attached Files

  9. #9

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: option button dosnt show the choice when i edit

    i have option1 option 2 option 3 with array or not dosnt matter ok?
    this is the code.
    --------------------
    CmbCust.Text = .SubItems(1)
    CmbCust.Enabled = False
    CmbHrDr.Text = FrmApps.LsVwHrDr.SelectedItem.Text
    CmbHrDr.Enabled = False
    PckDate.Value = .Text
    CmbStart.Text = Right$(.SubItems(2), 5)
    CmbEnd.Text = Mid$(.SubItems(2), 1, 5)
    TxtService.Text = .SubItems(3)
    Txtcash.Text = .SubItems(4)
    Option3(7).Value = True
    what im trying to do is if i pick the option1 that is fix and i save it
    and i press edit to change i will see that option1 is marked(i meen value is true)
    get it?
    and so on and on

  10. #10

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: option button dosnt show the choice when i edit

    this is example of option 1

    Private Sub Option1_Click(Index As Integer)
    If Option1(5).Value = True Then
    Txtcash.Text = "fix"
    End If
    End Sub

  11. #11
    Lively Member mikorians's Avatar
    Join Date
    Jun 2010
    Location
    In a fog
    Posts
    83

    Re: option button dosnt show the choice when i edit

    Here's a new sample that also retrieves the option buttons caption and drops it onto txtcash.text also
    Attached Files Attached Files

  12. #12
    Lively Member mikorians's Avatar
    Join Date
    Jun 2010
    Location
    In a fog
    Posts
    83

    Re: option button dosnt show the choice when i edit

    'K here's my laaaasssst attempt to please you. This includes a textbox text parser to change the option selection.
    Attached Files Attached Files
    Last edited by mikorians; Sep 24th, 2012 at 05:13 PM.

  13. #13

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: option button dosnt show the choice when i edit

    this didnt help me friend
    tnx anyway

  14. #14
    Lively Member mikorians's Avatar
    Join Date
    Jun 2010
    Location
    In a fog
    Posts
    83

    Re: option button dosnt show the choice when i edit

    Last word -
    Examine carefully the array of controls on your form - see that my own are all option1(n), I think it is not smart that VB doesn't remove the trailing number when you make an array of controls- should read:
    option(n) - don't let VB confuse you about which array is which on your own program - you must specify EXACTLY which control you're addressing in the subs in code as well as on the form controls.
    CYa

  15. #15
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: option button dosnt show the choice when i edit

    Salsa....if you really want some help, upload your project.....your explanation leaves me bewildered. And why all those option buttons??? Anyway, will be very willing to assist, but need better explanation of what you are trying to do, and the best way is to include your project in your explanation. Cheers.

  16. #16
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: option button dosnt show the choice when i edit

    Quote Originally Posted by salsa31 View Post
    i tried that too didnt work
    and i tried without en array and still didnt work
    i tried option1.value = true
    and so on
    no luck
    What do you mean by tried that too?

    Your code that you showed
    Code:
    If .SubItems(5) = "fixed" Then
    Option1(5).Value = True
    End If
    If .SubItems(6) = "not fixed" Then
    Option2(6).Value = True
    End If
    Option3(7).Value = True
    Would result in option3(7) being ticked and the others not being ticked no matter what the outcome of the if tests were unless your option buttons are in different containers on your form.

    There is no reason at all to use arrays as you have here. Either you should be using 1 array with 3 option buttons in it or no array. Setting up an array large enough to hold 8 elements when you only intend to use one and then placing that one at element 8 is not in any way a good idea and indicates that you really do not have a clue what you are doing here.

  17. #17

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: option button dosnt show the choice when i edit

    Quote Originally Posted by DataMiser View Post
    What do you mean by tried that too?

    Your code that you showed
    Code:
    If .SubItems(5) = "fixed" Then
    Option1(5).Value = True
    End If
    If .SubItems(6) = "not fixed" Then
    Option2(6).Value = True
    End If
    Option3(7).Value = True
    Would result in option3(7) being ticked and the others not being ticked no matter what the outcome of the if tests were unless your option buttons are in different containers on your form.

    There is no reason at all to use arrays as you have here. Either you should be using 1 array with 3 option buttons in it or no array. Setting up an array large enough to hold 8 elements when you only intend to use one and then placing that one at element 8 is not in any way a good idea and indicates that you really do not have a clue what you are doing here.
    what you suggest i do?

  18. #18
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: option button dosnt show the choice when i edit

    I can't really suggest much as I do not know what you are doing or trying to do. You haven't given us much info so all I can see at this point is that you are using control arrays incorrectly and your logic on the options is off. I would need more info to suggest proper logic for the task at hand.

  19. #19
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: option button dosnt show the choice when i edit

    Ditto

  20. #20

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: option button dosnt show the choice when i edit

    Quote Originally Posted by DataMiser View Post
    I can't really suggest much as I do not know what you are doing or trying to do. You haven't given us much info so all I can see at this point is that you are using control arrays incorrectly and your logic on the options is off. I would need more info to suggest proper logic for the task at hand.
    what i wrote here is all the code that i have in my form

  21. #21
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: option button dosnt show the choice when i edit

    If that is true then your program would give a bunch of errors
    Code:
        If .SubItems(5) = "fixed" Then
            Option1(5).Value = True
        End If
        If .SubItems(6) = "not fixed" Then
            Option2(6).Value = True
        End If
        Option3(7).Value = True
    
    End With
    Missing With statement
    Nothing is assigned to the .subitems of what I assume is a listview control somewhere that has been populated with data through code somewhere else.
    You show a click event which seemed to make reference to another form
    You mention that you are trying to edit something but not a hint as to what or how


    It is clear that you do have other code there and that you have not provided the proper info for anyone to help you

  22. #22
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: option button dosnt show the choice when i edit

    Please don't take this as an offense...we are here to try to help you, but your explanation is far from adequate.

    You say that is all that is on your form....that's ALL the code you have?

    What is this: FrmApps.LsVwHrDr....is this the name of THIS form or another form? What is LsVwHrDr?
    when you use .subItems (that is, a dot(.), there has to be something that this is a subitem of.....you have to use this within a WITH statement....you don't have that on your form.

    You are confused (as are we) about your use of option buttons. As we can't really tell what you are attempting to do, let me make a suggestion.

    Put an option button on your form. Copy it, and paste it three times on your form. This will give you option1(0), option1(1), option1(2) and option1(3). Delete option1(0).

    So now you will have three option buttons on your screen. I am ASSUMING the CmbHrDr amd cmbCust are comboboxes (although the usually naming convention is cboXXXX, not cmbXXXX. Why are they not enabled? You don't want the user to click on them???? Then why use comboboxes (IF that is what they are). Same goes if these cmb....objects are textboxes...if you don't want user inputs, make them labels and forget about the enable.

    So, there you have it.

    I have a form with three option buttons of array option1. I have 4 comboboxes named as in your code. I hve two textboxes named as in your code.

    Now, what do you want your program to do?

  23. #23

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: option button dosnt show the choice when i edit

    ihave 3 option buttons
    option1 = yes
    option 2 = no
    option 3 = maybe
    now what i did is
    If Option1(5).Value = True Then
    Txtcash.Text = "yes"
    End If
    If Option2(6).Value = True Then
    Txtcash.Text = "no"
    End If
    If Option3(7).Value = True Then
    Txtcash.Text = "maybe"
    End If
    what i need is that when i edit the customer that the option that i saved before will be marked.
    e.x
    lets say i choose for the cust option number 2
    that is no
    and when i edit and want to change
    i will see that option 2 is marked wth the dot inside of it
    i will see the option that i choosed before get it?

  24. #24
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: option button dosnt show the choice when i edit

    Eres Hispano?

  25. #25
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: option button dosnt show the choice when i edit

    ok since no one knows what he wants i tried myself to create a sample code that might help him/her hopefully... if not please give us what is it that needs to be Fixed/Not Fixed? a car? a computer? an airplane? a house? a xbox? a word?

    Edit: From Salsa to SpicySalsa
    Attached Files Attached Files
    Last edited by Max187Boucher; Sep 26th, 2012 at 06:11 PM.

  26. #26

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: option button dosnt show the choice when i edit

    Quote Originally Posted by SamOscarBrown View Post
    Eres Hispano?
    claro que si hombre

  27. #27
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: option button dosnt show the choice when i edit

    por favor explica la problema en espanol

    Mi espose esta de Mexico.....pero yo hablo un poquita

  28. #28
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: option button dosnt show the choice when i edit

    You really should keep the posts in English and use a PM if you need to use another language.

  29. #29
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: option button dosnt show the choice when i edit

    So what was your solution salsa?

  30. #30
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: [RESOLVED] option button dosnt show the choice when i edit

    Sorry Data.....

  31. #31
    Junior Member
    Join Date
    Sep 2012
    Location
    Cascais, Portugal
    Posts
    31

    Re: [RESOLVED] option button dosnt show the choice when i edit

    Error in SamOscarBrown's code! "el" not "la" -- "problema" is a masculine noun. :-)

    Seriously, though, it would be nice to know what the final solution was to -- no offence intended -- a quite confusing post.

  32. #32

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: [RESOLVED] option button dosnt show the choice when i edit

    no solotion i just left it hanging cuase i didnt get any answers
    i just made a option button that is called make en option and set the value to true

  33. #33
    Junior Member
    Join Date
    Sep 2012
    Location
    Cascais, Portugal
    Posts
    31

    Re: [RESOLVED] option button dosnt show the choice when i edit

    Does the attached code help?
    Attached Files Attached Files

  34. #34
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,622

    Re: [RESOLVED] option button dosnt show the choice when i edit

    Hey Mark...thanks for the Spanish lesson.....I did not know that problema was masculine (nor did my Mexican spouse!!!!).....thanks..I'll put that in my memory bank...what's left of it.

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