[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
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
Re: option button dosnt show the choice when i edit
Originally Posted by mikorians
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
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.
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?
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
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
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.
Re: option button dosnt show the choice when i edit
Originally Posted by salsa31
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.
Re: option button dosnt show the choice when i edit
Originally Posted by DataMiser
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.
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.
Re: option button dosnt show the choice when i edit
Originally Posted by DataMiser
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
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
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.
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?
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
Last edited by Max187Boucher; Sep 26th, 2012 at 06:11 PM.
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.