-
December 10th, 2009, 02:53 PM
#1
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.
-
December 10th, 2009, 07:01 PM
#2
Re: Simple If then Else Statement
Originally Posted by temoty
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..
-
December 10th, 2009, 08:26 PM
#3
Re: Simple If then Else Statement
anyone at all want to try and help?
-
December 10th, 2009, 10:34 PM
#4
Re: Simple If then Else Statement
Originally Posted by Bahamut666
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!
-
December 11th, 2009, 02:17 PM
#5
Re: Simple If then Else Statement
-
December 12th, 2009, 12:58 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|