Results 1 to 8 of 8

Thread: [RESOLVED] Using Constructor Event Creates Errors...

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2010
    Posts
    178

    Resolved [RESOLVED] Using Constructor Event Creates Errors...

    I created an even on a form called Sub New so I can handle some events and close the window down if there is an error.

    Upon doing that, I came across 3 errors that I don't know how to fix.

    vb.net Code:
    1. Me.Hide()
    2.  
    3.         frmEmail.SetReportDate = #1/23/2012#
    4.         frmEmail.Show()
    5.         frmEmail.Dispose()
    6.  
    7.         Me.Show()

    I get 3 errors, on lines 3, 4 and 5
    Reference to a non-shared member requires an object reference
    How can I fix this? Note: ShowDialog really isn't necessary I could just use .Show. I want to use ShowDialog because the line under those 3 shows the current form.


    Found the problem (I had private sub new) but now a new problem...
    How do I pass the date to the form?

    In case it's relavent, my code for sub new on frmEmail.
    vb.net Code:
    1. Public Sub New()
    2.         ' This call is required by the designer.
    3.         InitializeComponent()
    4.  
    5.         ' Add any initialization after the InitializeComponent() call.
    6.         Dim strHTML As String = String.Empty
    7.         Dim Subject As String = "Service Assignments for " & ReportDate.ToString(myDateFormat)
    8.         Dim oApp As Outlook._Application
    9.         Dim oMsg As Outlook._MailItem
    10.         Dim YesNo As DialogResult = Windows.Forms.DialogResult.Yes
    11.         Dim NoErrors As Boolean
    12.  
    13.         Me.Text = "Service Assignments for " & ReportDate.ToLongDateString
    14.  
    15.         setHeader()
    16.         NoErrors = setData()
    17.         setFooter()
    18.  
    19.         strHTML = reportHeader & reportData.ToString & reportFooter
    20.  
    21.         oApp = New Outlook.Application()
    22.         oMsg = CType(oApp.CreateItem(Outlook.OlItemType.olMailItem), Outlook._MailItem)
    23.  
    24.         oMsg.Subject = Subject
    25.         oMsg.HTMLBody = strHTML
    26.  
    27.         oMsg.To = "DTGOn-RentHelpDesk"
    28.         oMsg.CC = "[email protected]; [email protected]"
    29.  
    30.         oMsg.Importance = Outlook.OlImportance.olImportanceHigh
    31.  
    32.         oMsg.Display()
    33.  
    34.         YesNo = MessageBox.Show("Did the email show up?", Application.ProductName, _
    35.                                 MessageBoxButtons.YesNo, MessageBoxIcon.Question, _
    36.                                 MessageBoxDefaultButton.Button1)
    37.  
    38.         If Not NoErrors Then
    39.             Me.Close()
    40.         Else
    41.             If YesNo = Windows.Forms.DialogResult.No Then
    42.                 ieWeb.Document.Write(strHTML)
    43.                 Me.Show()
    44.             Else
    45.                 MessageBox.Show("Push Send in the email window to send!", "Send Email Alert", _
    46.                                 MessageBoxButtons.OK, MessageBoxIcon.Information)
    47.                 NoErrors = False
    48.                 oMsg2 = oMsg
    49.             End If
    50.         End If
    51.     End Sub
    Last edited by TrickyNick; Jan 27th, 2012 at 06:21 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width