LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default 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



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF sum is GreaterThan 0... why wont this work!? Tan. Excel Worksheet Functions 3 January 18th 06 09:36 PM
Control + C wont work WREFORD Excel Discussion (Misc queries) 3 August 25th 05 04:44 PM
macro wont work Dan Excel Programming 1 March 2nd 05 04:41 PM
Why Wont This Work? VBA Help Needed! Celtic_Avenger[_45_] Excel Programming 1 September 19th 04 02:21 PM
Sumproduct wont work Mycotopian[_3_] Excel Programming 2 August 5th 04 08:06 PM


All times are GMT +1. The time now is 03:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"