Results 1 to 4 of 4

Thread: TRY, IF, THEN error ... need help please ...

  1. #1
    Join Date
    Mar 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default TRY, IF, THEN error ... need help please ...

    Can someone help me with this please? I have a form on a .NET webserver using aspx pages with the vb code-behind pages. The form collects the entered data and then emails it, that part works fine.

    Right after it gets emailed, this code checks to see if the email was sent or not and then updates the landing page accordingly. I used to use just an IF THEN statement, but now that doesn't work in these new .NET pages.

    Here's the end of the code that I am having difficulties with:


    Code:
    Try
        Mail.Send()
        Mail = Nothing
    
    Catch ex As Exception
        Response.Write("There has been an error and your message WAS NOT SENT through email." & Err.Description)
           
    Finally
        If Mail >= 1 Then
              Response.Write("It worked, your form has been submitted by email!!!")
        End If
    
    End Try
    Specifically, this is the part that's throwing the error:

    Code:
    If Mail >= 1 Then
    The error is:
    Operator '>' is not defined for type 'IMailSend' and 'Nothing'

    is there a better way to write this whole block of code?

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Well, there is a reason for that: your code doesn't make sense. How could it be >= 1? It's either an IMailSend or a Nothing. How do those compare to 1?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Mar 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    OK, that makes sense but I'm to stupid to know how to fix it ...

    Would it be this then:

    Code:
    Try
        Mail.Send()
        Mail = Nothing
    
    Catch ex As Exception
        Response.Write("There has been an error and your message WAS NOT SENT through email." & Err.Description)
           
    Finally
        If Mail = IMailSend Then
              Response.Write("It worked, your form has been submitted by email!!!")
        End If
    
    End Try
    Am I close?

  4. #4
    Join Date
    Mar 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Nevermind, I got the answer. It should be:

    Code:
    Try
        Mail.Send()
        
    Response.Write("It worked, your form has been submitted by email!!!")
    
    Catch ex As Exception
        Response.Write("There has been an error and your message WAS NOT SENT through email." & Err.Description)
           
    Finally
       Mail = Nothing
    End Try
    I had everything backwards ...

Bookmarks

Posting Permissions

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