建议你做一个窗体,里面只放一个calendar控件
和取消,确定按钮
Private m_dDate As String
Private m_fIsOK As BooleanPublic Property Get IsOK() As Boolean
    IsOK = m_fIsOK
End PropertyPublic Property Get Value() As String
    Value = Format(m_dDate, "mm-dd-yyyy")
End PropertyPublic Property Let Value(ByVal dDate As String)
    m_dDate = dDate
    dte.Value = dDate
End PropertyPrivate Sub cmdCancel_Click()
    m_fIsOK = False
    Unload Me
End SubPrivate Sub cmdOK_Click()
    m_fIsOK = True
    m_dDate = dte.Value
    Unload Me
End SubPrivate Sub dte_DblClick()
    Call cmdOK_Click
End SubPrivate Sub dte_Click()
    Call cmdOK_Click
End Sub
Private Sub Form_Load()
    m_fIsOK = False
End Sub
-------------------------------------Private Sub cmdDate_Click()
    Dim sDate As String
    With frmDate
        sDate = cboDateStart.Text
        If sDate <> "" Then .Value = sDate
        .Show 1
        If .IsOK = True Then sDate = .Value
    End With
End Sub
------------------------
或者你不要这么做
定义一个全局变量
标注一下是那个按钮触发的

解决方案 »

  1.   

    Private Sub Calendar1_Click()
       Debug.Print Calendar1.Value
    End Sub
      

  2.   

    终于看懂了题意。~~~~~~~~~~
    楼上的说得对,定义一个模块级全局变量。
    最好将文本控件设为控件数组,再用全局整形变量进行标注就可以了。
    Button也用控件数组好了,其Index与文本控件一一对应。Dim mintIndex As IntegerPrivate Sub Calendar1_Click()
       txtDataArray(mintIndex) = Calendar1.Value
    End SubPrivate Sub Calendar1_LostFocus()
        Calendar1.Visible = False
    End SubPrivate Sub Command1_Click(Index As Integer)
       Calendar1.Visible = True
       Calendar1.SetFocus
       mintIndex = Index
    End Sub
      

  3.   

    呵呵 给你源代码:
    做一个窗体,放上Calender控件,代码如下:
    Public mydate As String
    Public flag As Boolean
    Private Sub Command1_Click()
        Dim frm  As Form
        Dim txt As TextBox
        Dim strTemp As String
        mydate = calDate.Year & "-" & calDate.Month & "-" & calDate.Day
        Me.Hide
    End SubPrivate Sub Form_Load()
        flag = False
    End SubPrivate Sub Form_Unload(Cancel As Integer)
        If flag = False Then
            Cancel = 0
        End If
    End Sub在模块中加入函数:
      Public Function GetDate() As String
     '设计自已的输入日期的函数
        frmDate.Show vbModal
        GetDate = frmDate.mydate
        frmDate.flag = True
        Unload frmDate
     End FunctionEnd Function