VS 2008 [RESOLVED] how to call MonthCalendar1_DateSelected from another form-VBForums
Results 1 to 5 of 5

Thread: [RESOLVED] how to call MonthCalendar1_DateSelected from another form

  1. #1

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,546

    Resolved [RESOLVED] how to call MonthCalendar1_DateSelected from another form

    Hi Guys,

    I have a month calendar on my form. under it's DateSelected Event I do a bunch of stuff. Now I want to call this event from another form. How can I do this?

    Code:
    Private Sub MonthCalendar1_DateSelected(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateSelected
    
    ....
    
    End Sub

  2. #2
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,652

    Re: how to call MonthCalendar1_DateSelected from another form

    Change Private to Public (or Friend in your code) and call it:

    vb.net Code:
    1. ' Must be known before the call is made
    2. Dim startDate As Date = #1/1/2010#
    3. Dim endDate As Date = #1/31/2010#
    4.  
    5. ' Prepare the event arguments:
    6. Dim e As New DateRangeEventArgs(startDate, endDate)
    7.  
    8. ' FormName here is a placeholder for your actual form that contains your MonthCalendar.
    9. Call FormName.MonthCalendar1_DateSelected(me, e)

  3. #3

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,546

    Re: how to call MonthCalendar1_DateSelected from another form

    thanks cicatrix

    I want the start and end date to be the current selected date of my month calendar. will try and figure it out now.

  4. #4
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,334

    Re: how to call MonthCalendar1_DateSelected from another form

    How about using properties
    vb.net Code:
    1. Public ReadOnly Property StartDate() As String
    2.     Get
    3.         Return txtStartDate.Text
    4.     End Get
    5.  
    6. End Property
    7.  
    8. Public ReadOnly Property EndDate() As String
    9.     Get
    10.         Return txtEndDate.Text
    11.     End Get
    12.  
    13. End Property
    then call them from whereever
    Code:
    'form form2
    txtStartDate.Text = Form1.StartDate
    txtEndDate.Text = Form1.EndDate
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  5. #5

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,546

    Re: how to call MonthCalendar1_DateSelected from another form

    thanks guys. problem has been resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.