Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Why wont this code work?
I'm trying to get the effect of a push button radio so only one at oce will
be pushed (ie all the others pop out if one is pressed). Strange thing is, if I go into design mode and run the code from within VB by say clicking on toggle button 1 and then step through it, it works! Maybe there's an easy way of doing this (grouping them) it seems to be the way most people would want to use them (like option buttons?). Any help much appreciated; stuff like this sucks up your time and attention so you can't do what you need to. Private bBlockEvent As Boolean Private Sub ToggleButton1_Click() If bBlockEvent = True Then Exit Sub If ToggleButton2 = True Then bBlockEvent = True ToggleButton2 = False End If If ToggleButton3 = True Then bBlockEvent = True ToggleButton3 = False End If If ToggleButton4 = True Then bBlockEvent = True ToggleButton4 = False End If If ToggleButton5 = True Then bBlockEvent = True ToggleButton5 = False End If If ToggleButton6 = True Then bBlockEvent = True ToggleButton6 = False End If End Sub Private Sub ToggleButton2_Click() If bBlockEvent = True Then Exit Sub If ToggleButton1 = True Then bBlockEvent = True ToggleButton1 = False End If If ToggleButton3 = True Then bBlockEvent = True ToggleButton3 = False End If If ToggleButton4 = True Then bBlockEvent = True ToggleButton4 = False End If If ToggleButton5 = True Then bBlockEvent = True ToggleButton5 = False End If If ToggleButton6 = True Then bBlockEvent = True ToggleButton6 = False End If End Sub Private Sub ToggleButton3_Click() If bBlockEvent = True Then Exit Sub If ToggleButton1 = True Then bBlockEvent = True ToggleButton1 = False End If If ToggleButton2 = True Then bBlockEvent = True ToggleButton2 = False End If If ToggleButton4 = True Then bBlockEvent = True ToggleButton4 = False End If If ToggleButton5 = True Then bBlockEvent = True ToggleButton5 = False End If If ToggleButton6 = True Then bBlockEvent = True ToggleButton6 = False End If End Sub Private Sub ToggleButton4_Click() If bBlockEvent = True Then Exit Sub If ToggleButton1 = True Then bBlockEvent = True ToggleButton1 = False End If If ToggleButton2 = True Then bBlockEvent = True ToggleButton2 = False End If If ToggleButton3 = True Then bBlockEvent = True ToggleButton3 = False End If If ToggleButton5 = True Then bBlockEvent = True ToggleButton5 = False End If If ToggleButton6 = True Then bBlockEvent = True ToggleButton6 = False End If End Sub Private Sub ToggleButton5_Click() If bBlockEvent = True Then Exit Sub If ToggleButton1 = True Then bBlockEvent = True ToggleButton1 = False End If If ToggleButton2 = True Then bBlockEvent = True ToggleButton2 = False End If If ToggleButton3 = True Then bBlockEvent = True ToggleButton3 = False End If If ToggleButton4 = True Then bBlockEvent = True ToggleButton4 = False End If If ToggleButton6 = True Then bBlockEvent = True ToggleButton6 = False End If End Sub Private Sub ToggleButton6_Click() If bBlockEvent = True Then Exit Sub If ToggleButton1 = True Then bBlockEvent = True ToggleButton1 = False End If If ToggleButton2 = True Then bBlockEvent = True ToggleButton2 = False End If If ToggleButton3 = True Then bBlockEvent = True ToggleButton3 = False End If If ToggleButton4 = True Then bBlockEvent = True ToggleButton4 = False End If If ToggleButton5 = True Then bBlockEvent = True ToggleButton5 = False End If End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Why wont this code work?
Why not use optionbuttons, they work that way by default.
-- HTH RP (remove nothere from the email address if mailing direct) "Mark Stephens" wrote in message ... I'm trying to get the effect of a push button radio so only one at oce will be pushed (ie all the others pop out if one is pressed). Strange thing is, if I go into design mode and run the code from within VB by say clicking on toggle button 1 and then step through it, it works! Maybe there's an easy way of doing this (grouping them) it seems to be the way most people would want to use them (like option buttons?). Any help much appreciated; stuff like this sucks up your time and attention so you can't do what you need to. Private bBlockEvent As Boolean Private Sub ToggleButton1_Click() If bBlockEvent = True Then Exit Sub If ToggleButton2 = True Then bBlockEvent = True ToggleButton2 = False End If If ToggleButton3 = True Then bBlockEvent = True ToggleButton3 = False End If If ToggleButton4 = True Then bBlockEvent = True ToggleButton4 = False End If If ToggleButton5 = True Then bBlockEvent = True ToggleButton5 = False End If If ToggleButton6 = True Then bBlockEvent = True ToggleButton6 = False End If End Sub Private Sub ToggleButton2_Click() If bBlockEvent = True Then Exit Sub If ToggleButton1 = True Then bBlockEvent = True ToggleButton1 = False End If If ToggleButton3 = True Then bBlockEvent = True ToggleButton3 = False End If If ToggleButton4 = True Then bBlockEvent = True ToggleButton4 = False End If If ToggleButton5 = True Then bBlockEvent = True ToggleButton5 = False End If If ToggleButton6 = True Then bBlockEvent = True ToggleButton6 = False End If End Sub Private Sub ToggleButton3_Click() If bBlockEvent = True Then Exit Sub If ToggleButton1 = True Then bBlockEvent = True ToggleButton1 = False End If If ToggleButton2 = True Then bBlockEvent = True ToggleButton2 = False End If If ToggleButton4 = True Then bBlockEvent = True ToggleButton4 = False End If If ToggleButton5 = True Then bBlockEvent = True ToggleButton5 = False End If If ToggleButton6 = True Then bBlockEvent = True ToggleButton6 = False End If End Sub Private Sub ToggleButton4_Click() If bBlockEvent = True Then Exit Sub If ToggleButton1 = True Then bBlockEvent = True ToggleButton1 = False End If If ToggleButton2 = True Then bBlockEvent = True ToggleButton2 = False End If If ToggleButton3 = True Then bBlockEvent = True ToggleButton3 = False End If If ToggleButton5 = True Then bBlockEvent = True ToggleButton5 = False End If If ToggleButton6 = True Then bBlockEvent = True ToggleButton6 = False End If End Sub Private Sub ToggleButton5_Click() If bBlockEvent = True Then Exit Sub If ToggleButton1 = True Then bBlockEvent = True ToggleButton1 = False End If If ToggleButton2 = True Then bBlockEvent = True ToggleButton2 = False End If If ToggleButton3 = True Then bBlockEvent = True ToggleButton3 = False End If If ToggleButton4 = True Then bBlockEvent = True ToggleButton4 = False End If If ToggleButton6 = True Then bBlockEvent = True ToggleButton6 = False End If End Sub Private Sub ToggleButton6_Click() If bBlockEvent = True Then Exit Sub If ToggleButton1 = True Then bBlockEvent = True ToggleButton1 = False End If If ToggleButton2 = True Then bBlockEvent = True ToggleButton2 = False End If If ToggleButton3 = True Then bBlockEvent = True ToggleButton3 = False End If If ToggleButton4 = True Then bBlockEvent = True ToggleButton4 = False End If If ToggleButton5 = True Then bBlockEvent = True ToggleButton5 = False End If End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
IF sum is GreaterThan 0... why wont this work!? | Excel Worksheet Functions | |||
Control + C wont work | Excel Discussion (Misc queries) | |||
macro wont work | Excel Programming | |||
Why Wont This Work? VBA Help Needed! | Excel Programming | |||
Sumproduct wont work | Excel Programming |