PASS comcobox name as public function

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

PASS comcobox name as public function

Post by sal21 »

Code: Select all

Private Sub FILL_GIORNI()

    Dim myVar As String
    Dim StartDate As Date
    Dim EndDate As Date
    Dim ThisDate As Date

    myVar = MESE & "-" & ANNO

    StartDate = CDate(myVar)
    EndDate = DateAdd("d", -1, DateAdd("m", 1, StartDate))

    With Me.CGIORNO
        .Clear
        For ThisDate = StartDate To EndDate
            .AddItem UCase(Format$(ThisDate, "DDD")) & "-" & ThisDate
        Next
    End With

End Sub
how to use in this code to pass the name of a combobox?

similar:
FILL_GIORNI(cmycombobox)

User avatar
HansV
Administrator
Posts: 78475
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: PASS comcobox name as public function

Post by HansV »

Code: Select all

Sub FILL_GIORNI(ctl As String)

    Dim myVar As String
    Dim StartDate As Date
    Dim EndDate As Date
    Dim ThisDate As Date

    myVar = MESE & "-" & ANNO

    StartDate = CDate(myVar)
    EndDate = DateAdd("d", -1, DateAdd("m", 1, StartDate))

    With Controls(ctl)
        .Clear
        For ThisDate = StartDate To EndDate
            .AddItem UCase(Format$(ThisDate, "DDD")) & "-" & ThisDate
        Next
    End With

End Sub
Best wishes,
Hans

User avatar
SpeakEasy
4StarLounger
Posts: 550
Joined: 27 Jun 2021, 10:46

Re: PASS comcobox name as public function

Post by SpeakEasy »

>pass the name of a combobox

Why do you want to pass the name rather than the combobox itself?

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

Re: PASS comcobox name as public function

Post by sal21 »

HansV wrote:
30 Mar 2022, 11:28

Code: Select all

Sub FILL_GIORNI(ctl As String)

    Dim myVar As String
    Dim StartDate As Date
    Dim EndDate As Date
    Dim ThisDate As Date

    myVar = MESE & "-" & ANNO

    StartDate = CDate(myVar)
    EndDate = DateAdd("d", -1, DateAdd("m", 1, StartDate))

    With Controls(ctl)
        .Clear
        For ThisDate = StartDate To EndDate
            .AddItem UCase(Format$(ThisDate, "DDD")) & "-" & ThisDate
        Next
    End With

End Sub
:cheers: :clapping: