LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Change event

Thanks, Kenneth.
I've taken the simpler route of creating a procedure to trap changes to each
OptionButton; however, I'm going to hold onto to your code and will include
it as I refine my "solution." Thanks for your help; I appreciate it!
Bert.



"Kenneth Hobson" wrote in message
...
As Leith said, doing it is a bit more effort than it may be worth.

Here is one way using the Click event rather than a Change event in a
Class.

1. Create your UserForm1 with the option buttons and TextBox1.
2. Add a class and use this code. Name the class in the project explorer
as cOptionButtons.

Private WithEvents obttn1 As MSForms.OptionButton

Sub SendOptionButton(ByVal obttn As MSForms.OptionButton)
Set obttn1 = obttn
End Sub

Private Sub obttn1_Click()
If obttn1.Value = True Then IncrementTB1 obttn1
End Sub

3. Add a Module with this code.

Sub IncrementTB1(ob As MSForms.OptionButton)
If UserForm1.TextBox1.Value = "" Then UserForm1.TextBox1.Value = "0"
UserForm1.TextBox1.Value = CStr(CDbl(UserForm1.TextBox1.Value) +
CDbl(ob.Tag))
End Sub

4. Add this code to UserForm1. The use of the Tag property makes this a
bit easier.

Dim ob() As cOptionButtons

Private Sub UserForm_Initialize()
Dim obj As MSForms.Control, i As Long

For Each obj In Me.Controls
If TypeName(obj) = "OptionButton" Then
i = i + 1
ReDim Preserve ob(i)
Set ob(i) = New cOptionButtons
ob(i).SendOptionButton obj
obj.Tag = i
End If
Next
End Sub

Private Sub CommandButton1_Click()
MsgBox TextBox1.Value
Unload Me
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
apply cell change event to single column - WorksheetChange Event [email protected] Excel Programming 6 May 4th 08 02:28 AM
How do I change a Worksheet_change event to a beforesave event? Tueanker Excel Programming 5 June 29th 07 03:00 PM
MsgBox in Enter event causes combobox not to run Change event Richard Excel Programming 0 March 6th 06 02:52 PM
Change event and calculate event Antje Excel Programming 1 March 29th 05 09:03 PM
change event/after update event?? scrabtree23[_2_] Excel Programming 1 October 20th 03 07:09 PM


All times are GMT +1. The time now is 05:27 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"