If Then

Discussion in 'ASP General' started by paulmitchell507, Sep 3, 2008.

  1. I am designing a small .asp (classic) application, I am connecting to
    a Access 2k database via ADO to retrieve data. I have a number
    variable's that contain text that is posted from a previous screen

    AMPM = Request.Form("AMPM")
    AMPMDate = Request.Form("AMPMDate")
    halfday = "(" & AMPM & "," & AMPMDate & ")"

    I then compose a CDOSYS email and send the value of the variable in
    the .HTML body of the email

    ..HTML = "Number of Days" & halfday

    What I would like to do is only display the value of the halfday
    variable if it contains a value. I was thinking along the lines of

    If halfday = Null Then
    halfday = ""

    Else

    halfday = halfday

    End if

    I know this does not work, but it gives an idea of what I am trying to
    achieve.
    Any help would be appreciated.

    Regards
     
    paulmitchell507, Sep 3, 2008
    #1
    1. Advertising

  2. paulmitchell507 wrote:
    > I am designing a small .asp (classic) application, I am connecting to
    > a Access 2k database via ADO to retrieve data. I have a number
    > variable's that contain text that is posted from a previous screen
    >
    > AMPM = Request.Form("AMPM")
    > AMPMDate = Request.Form("AMPMDate")
    > halfday = "(" & AMPM & "," & AMPMDate & ")"
    >
    > I then compose a CDOSYS email and send the value of the variable in
    > the .HTML body of the email
    >
    > .HTML = "Number of Days" & halfday
    >
    > What I would like to do is only display the value of the halfday
    > variable if it contains a value. I was thinking along the lines of
    >
    > If halfday = Null Then


    This will never be true. Comparisons to Null always result in Null. You
    probably mean:

    If halfday Is Null Then

    However, this will also never be the case at this point because in your
    previous statements, you assigned values to halfday. I think what you
    intend to do is something like;

    If AMPM = "" And AMPMDate = "" then
    halfday=""
    Else
    halfday = "(" & AMPM & "," & AMPMDate & ")"
    End if


    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Sep 3, 2008
    #2
    1. Advertising

  3. "Bob Barrows [MVP]" <> wrote in message
    news:...
    > paulmitchell507 wrote:
    >> I am designing a small .asp (classic) application, I am connecting to
    >> a Access 2k database via ADO to retrieve data. I have a number
    >> variable's that contain text that is posted from a previous screen
    >>
    >> AMPM = Request.Form("AMPM")
    >> AMPMDate = Request.Form("AMPMDate")
    >> halfday = "(" & AMPM & "," & AMPMDate & ")"
    >>
    >> I then compose a CDOSYS email and send the value of the variable in
    >> the .HTML body of the email
    >>
    >> .HTML = "Number of Days" & halfday
    >>
    >> What I would like to do is only display the value of the halfday
    >> variable if it contains a value. I was thinking along the lines of
    >>
    >> If halfday = Null Then

    >
    > This will never be true. Comparisons to Null always result in Null. You
    > probably mean:
    >
    > If halfday Is Null Then
    >


    Your VBScript getting a bit rusty Bob? ;)

    If IsNull(halfday) Then

    The Is keyword in VBScript tests the type of an object (via the
    QueryInterface method).

    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Sep 4, 2008
    #3
  4. On Sep 4, 9:08 am, "Anthony Jones" <>
    wrote:
    > "Bob Barrows [MVP]" <> wrote in messagenews:...
    >
    >
    >
    >
    >
    > > paulmitchell507 wrote:
    > >> I am designing a small .asp (classic) application, I am connecting to
    > >> a Access 2k database via ADO to retrieve data.  I have a number
    > >> variable's that contain text that is posted from a previous screen

    >
    > >> AMPM = Request.Form("AMPM")
    > >> AMPMDate = Request.Form("AMPMDate")
    > >> halfday = "(" & AMPM & "," & AMPMDate & ")"

    >
    > >> I then compose a CDOSYS email and send the value of the variable in
    > >> the .HTML body of the email

    >
    > >> .HTML = "Number of Days" & halfday

    >
    > >> What I would like to do is only display the value of the halfday
    > >> variable if it contains a value.  I was thinking along the lines of

    >
    > >> If halfday = Null Then

    >
    > > This will never be true. Comparisons to Null always result in Null. You
    > > probably mean:

    >
    > > If halfday Is Null Then

    >
    > Your VBScript getting a bit rusty Bob? ;)
    >
    > If IsNull(halfday) Then
    >
    > The Is keyword in VBScript tests the type of an object (via the
    > QueryInterface method).
    >
    > --
    > Anthony Jones - MVP ASP/ASP.NET- Hide quoted text -
    >
    > - Show quoted text -


    Bob's VBScript may/may not be a bit rusty (I am not qualified to
    judge, hence my question) but it worked for me!
    Thank you both very much for your help.
     
    paulmitchell507, Sep 4, 2008
    #4
  5. Anthony Jones wrote:
    >>> What I would like to do is only display the value of the halfday
    >>> variable if it contains a value. I was thinking along the lines of
    >>>
    >>> If halfday = Null Then

    >>
    >> This will never be true. Comparisons to Null always result in Null.
    >> You probably mean:
    >>
    >> If halfday Is Null Then
    >>

    >
    > Your VBScript getting a bit rusty Bob? ;)
    >
    > If IsNull(halfday) Then
    >
    > The Is keyword in VBScript tests the type of an object (via the
    > QueryInterface method).


    Oops. Doing too much sql lately ...

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Sep 4, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TWlrZQ==?=

    greater then / less then

    =?Utf-8?B?TWlrZQ==?=, Nov 4, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,604
    Kevin Spencer
    Nov 4, 2004
  2. JosephByrns

    Slow, then quick then slow

    JosephByrns, Jul 10, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    2,508
    codezilla94
    Nov 13, 2007
  3. Mufasa
    Replies:
    7
    Views:
    426
    Alexey Smirnov
    Sep 4, 2007
  4. Replies:
    0
    Views:
    316
  5. Replies:
    4
    Views:
    553
    cwdjrxyz
    Jan 17, 2006
Loading...

Share This Page