I'm looking at code that links a button created on a userform at runtime with some code in a class module.
I don't understand the use of the tag property here. is it just so that if the user wants to they can extract the identity of a certain button?
Wouldn't "control.name & i" have worked for that?
Code:
For Each obj In Me.Controls
If TypeName(obj) = "CommandButton" Then
If Left(obj.Name, 3) = "dyn" Then
i = i + 1
ReDim Preserve c(i)
Set c(i) = New Class1
c(i).SetCommandButton obj
obj.Tag = i
End If
End If
Next
End Sub
Creating controls at runtime is not my forte. It may simply be a matter of taste. I guess it depends on how the tag value is used (if at all) later on - perhaps it's a convenience. Sometimes you just do what you're used to doing, even if other (better) ways exist.
We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel
Which adblocker are you using?
Disable AdBlock
Follow these easy steps to disable AdBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the icon in the browser’s toolbar. 2)Click on the "Pause on this site" option.
Go back
Disable AdBlock Plus
Follow these easy steps to disable AdBlock Plus
1)Click on the icon in the browser’s toolbar. 2)Click on the toggle to disable it for "mrexcel.com".
Go back
Disable uBlock Origin
Follow these easy steps to disable uBlock Origin
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.
Go back
Disable uBlock
Follow these easy steps to disable uBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.