I have searched and tried for 6 hours now but I can't solve the problem.
My idea: I want to show a userform in Excel-VBA with some radiobuttons, one listelement and one textfield. I want to pass some arguments to the userform to work with it because I don't want to calculate inside the userform-code (which works) I don't want to declare global variables as well.
I tried the following which worked:
calculate directly in the userform
global variables
This hasn't worked:
declared userform as variable and worked with the variable
every possible combination of
[Public|Private|Friend] Property Let (ByRef|ByVal)
Property Set
doesn't work in any case
The code from my main (module)
Option Explicit
Sub main()
With New usr_mainInput
.counter = 3
.Show
End With
End Sub
My code in the userform
Option Explicit
Private miCounter As Integer
Property Get counter() As Integer
counter = miCounter
End Property
Property Let counter(c As Integer)
Set miCounter = c
End Property
Private Sub userform_initialize()
Dim i As Integer
For i = 1 To counter 'miCounter don't work as well
Debug.Print i
Next i
End Sub
Private Sub btn_ok_Click()
Me.Hide
End Sub
Object variable or With block variable not set
If it comes to the Property Let counter()
it drops a compile error:
Object required (Error 424)
Set
inProperty Let counter()
. – Brian M Stafford_initialize
is to early, the.counter
isn't set at this time and in theProperty Let counter()
I don't have toSet miCounter = c
, that's the cause of the dropped error. With_activate
it works. I'll try tomorow in the office with my live-program, this was just a short reconstruction. – Patrick