Hello

I have 3 frame, in each I have 3 option buttons,


If the user enters option 1, it should make option 4 and option 7 not available

If the user enters option 2, it should make option 5 and option 8 not available, but make rest of the option available

If the user enters option 3, it should make option 6 and option 9 not available, but make rest of the option available

If the user enters option 4, it should make option 1 and option 7 not available, but make rest of the option available

If the user enters option 5, it should make option 2 and option 8 not available, but make rest of the option available

If the user enters option 6, it should make option 3 and option 9 not available, but make rest of the option available

If the user enters option 7, it should make option 1 and option 4 not available, but make rest of the option available

If the user enters option 8, it should make option 2 and option 5 not available, but make rest of the option available

If the user enters option 9, it should make option 3 and option 6 not available, but make rest of the option available

this can be done, by using the following code

Option1.enable = true
Option 4.enable = false
Option7.enable = false

To make it fully work I will need about 27 lines of code, is there a easy way of doing it, please remember that the user will need 3 different option buttons, can we use the if , else statement, and how can we make it work please help me, I really don’t want to write 27 lines of code, mainly because I may have 5 options in each frame that would make it 125 lines of code, please show me a easy method with an example please

WEll this is the only way to do it

You could do it with an elseif, but your best bet is to simply add the required code to each option button. This makes the code more readible, more modular, and more understandble.

if the elseif code was used, how would it work, can you please show me a demo, i have tried to use it but won't work, and if i do each option alone and have 15 options buttons then i will need 125 line of code, there must be a easy way, right???

Even with an elseif or select case, you're going to have a crap load of code to do exactly what you need done. If you know the elseif layout, then it would be something like:

if option1.value = true then
    option4.enabled = false
    option7.enabled = false
    ' and set all the others to enabled = true
ElseIf option2.value = true then
    option5.enabled = false
    option8.enabled = false
    ' and set all the other to enabled = true
end if

Now, if they were control arrays (the option buttons) all with the name of option1 then you can set everything to enabled = true by simply doing something like:

for I = 0 to option1.count -1
     option1(I).enabled = true
next I

But that's only going to fly in a control array, and you'll still need an if statement for each button that you want to NOT get set to true..... my opinion is, to quit looking for ways to avoid writing the code, and just do it. You'll get it done faster that way.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.