Click to See Complete Forum and Search --> : Simple If then Else Statement
temoty
December 10th, 2009, 01:53 PM
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.
Bahamut666
December 10th, 2009, 06:01 PM
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..
temoty
December 10th, 2009, 07:26 PM
anyone at all want to try and help?
temoty
December 10th, 2009, 09:34 PM
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!
temoty
December 11th, 2009, 01:17 PM
anyone anyone?
kristof1104
December 12th, 2009, 11:58 AM
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)
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.