CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2006
    Posts
    23

    Unhappy Simple If then Else Statement

    I really need some help for a work project I'm doing.

    It's been a long time since I wrote VB script on a .asp file.

    I need to write something like this, but it's not working:

    ___________________________________________


    <%
    Dim ToEmail

    IF frmOffice = "Projects"
    Then ToEmail = "123@hotmail.com"
    If frmOffice = "Systems"
    Then ToEmail = "321@hotmail.com"
    If frmOffice = "Developers"
    Then ToEmail = "543@hotmail.com"
    END IF
    %>

    _______________________________

    Can you please tell me how to write this?

    I'm trying to say if the form's text box has "projects, systems, or developers" in it, then the application sends an automatic email to a specific email address, which is correlated to the text box content.

    I'm not getting an error, so I don't think there is a lot wrong with my code above....Can you tell me?

    thanks,

    This has really been stumping me.....I know it's not that complicated.

  2. #2
    Join Date
    Dec 2009
    Location
    VB8.0/.net frame 2.0SP2
    Posts
    1

    Re: Simple If then Else Statement

    Quote Originally Posted by temoty View Post
    I really need some help for a work project I'm doing.

    It's been a long time since I wrote VB script on a .asp file.

    I need to write something like this, but it's not working:

    ___________________________________________


    <%
    Dim ToEmail

    IF frmOffice = "Projects"
    Then ToEmail = "123@hotmail.com"
    If frmOffice = "Systems"
    Then ToEmail = "321@hotmail.com"
    If frmOffice = "Developers"
    Then ToEmail = "543@hotmail.com"
    END IF
    %>

    _______________________________

    Can you please tell me how to write this?

    I'm trying to say if the form's text box has "projects, systems, or developers" in it, then the application sends an automatic email to a specific email address, which is correlated to the text box content.

    I'm not getting an error, so I don't think there is a lot wrong with my code above....Can you tell me?

    thanks,

    This has really been stumping me.....I know it's not that complicated.
    I will be the first to admit to being a newbie here and to programming in general as just finished an intro course to VB2005. So I am not familiar with the syntax for answering your question.

    BUT why don't you put in an else statement that will display the value of frmOffice variable to make verify what is being compared. Since from the sounds of what is happening and looking at your code the script is just going through the if statements and not matching anything so it falls out the other end after having done its job.

    in VB'05 the code would be more like

    <%
    Dim ToEmail, frmOffice as string

    IF frmOffice = "Projects" then
    ToEmail = "123@hotmail.com"
    elseif frmOffice = "Systems" then
    ToEmail = "321@hotmail.com"
    elseif frmOffice = "Developers" then
    ToEmail = "543@hotmail.com"
    else
    label.text = frmOffice
    END IF
    %>

    or however you do it in your scripting language just display the variables after your if/then structure is finished to verify the data in them .. once you get it working then remove the additional statements..

  3. #3
    Join Date
    Feb 2006
    Posts
    23

    Re: Simple If then Else Statement

    anyone at all want to try and help?

  4. #4
    Join Date
    Feb 2006
    Posts
    23

    Re: Simple If then Else Statement

    Quote Originally Posted by Bahamut666 View Post
    I will be the first to admit to being a newbie here and to programming in general as just finished an intro course to VB2005. So I am not familiar with the syntax for answering your question.

    BUT why don't you put in an else statement that will display the value of frmOffice variable to make verify what is being compared. Since from the sounds of what is happening and looking at your code the script is just going through the if statements and not matching anything so it falls out the other end after having done its job.

    in VB'05 the code would be more like

    <%
    Dim ToEmail, frmOffice as string

    IF frmOffice = "Projects" then
    ToEmail = "123@hotmail.com"
    elseif frmOffice = "Systems" then
    ToEmail = "321@hotmail.com"
    elseif frmOffice = "Developers" then
    ToEmail = "543@hotmail.com"
    else
    label.text = frmOffice
    END IF
    %>

    or however you do it in your scripting language just display the variables after your if/then structure is finished to verify the data in them .. once you get it working then remove the additional statements..
    thanks, I just don't uderstand your "label.text = frmOffice" part??

    Also, can you show me the other version you're mentioning with the variables displayed AFTER the IF then Else structure??

    thanks a lot!

  5. #5
    Join Date
    Feb 2006
    Posts
    23

    Re: Simple If then Else Statement

    anyone anyone?

  6. #6
    Join Date
    Sep 2006
    Posts
    31

    Re: Simple If then Else Statement

    Do you use asp or asp.net
    if you use ASP.NET
    you make a <asp:label ID="label1" runat="server"/> tag in your aspx page

    and
    label.text = frmOffice
    fills in the text into that label

    if you use ASP you can use
    Response.Write(frmOffice)
    Last edited by kristof1104; December 12th, 2009 at 01:00 PM.

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

Featured