Greetings and Salutations,
Preface:
While designing a UserForm (hereafter, form), I experienced an issue with the calendar control (shocked,eh?). I noted that when going from an older (2000) App version to a newer App version (2003), the buttons (or at least the font on the buttons, I forget which) became incredibly small. I would note that I think I still was in Word, but I do not see that having any bearing.
Hence – I decided it was time to tackle something a tad bigger using class module(s) than I had heretofore. I decided to build myself a handy-dandy pseudo ‘calendar control,’ which is of course, something like 52 controls to replicate the Calendar control… Stop giggling.
Code Goal:
I would like to improve upon what I have done so far, and hopefully improve my understanding of when Set/Let/Get are advantageous, as well as efficiently referencing child/sub classes and parent classes. I admit that I may be using those terms incorrectly, but hope I am close.
After this thread, I am hoping to be able to add a couple of/few ‘stock’ classes to a project; a few lines of code to a form, and viola – a pseudo calendar control would be usable. Again, stop giggling; I can do it!
Reference the pseudo calendar control, or PCal for short – while I have seen several of examples of creating a calendar on a form (there are very nice examples in our KB), I was thinking a bit differently; something that might be easily sizeable, visible = true/false and such. That is not to say that such examples do not exist; as King Solomon mentioned, there is nothing new under the Sun. Regardless, I have not run into any.
I’m rather happy with what I’ve mustered so far, but at this point, am looking forward to hearing, “Yikes! You should do this in this part, and here’s why…”
Question:
Specific to a form, when the Initialize event creates an instance of a class, and we need the created class to be able to refer to the form:[vba]Private Sub ThisPButton_Click()
- Why is not the passed reference able to access all of the properties of the form? For instance (and being the bright lad I am, I’ll bet that this is important), the .Name property is gone?
- Does the below seem a reasonable method, or is there a better way (see the bottom of ThisPButton_Click in cls_pcalPButton in the attachment)?
'...statements....
n = -1
For Each UserForm In UserForms
If UserForm.Name = PCalParentForm.Name Then
n = n + 1
UserForms(n).PCalDateLong = CDate(cPCal.DateLongPicked)
Call UserForms(n).AssignDate(CDate(cPCal.DateLongPicked))
If cPCal.AssignReturnToControl Then
cPCal.PushDateToCtrl cPCal.Caller, VbLet, cPCal.DateLongPicked
End If
'***TESTING***
UserForms(n).Caption = Space(2) & UCase(Format(CDate(cPCal.DateLongPicked), "dd mmm yyyy"))
Exit For
End If
Next
End Sub[/vba]
Due to the time here, I will have to check back tonight, but have been meaning to post (where does the day fly to so quickly?).
Thank you so much,
Mark