"if" question

  • Thread starter Thread starter Miguel Dias Moura
  • Start date Start date
M

Miguel Dias Moura

Hello,

i have this code line in a script in my ASP.net / VB web site:

if msgNewsletterAction = "Go" Then
code1
Else
code2
End If

code2 runs everytime even when msgNewsletterAction = "Go". code1 never runs.

What is wrong in my sintax?

Thank You,
Miguel
 
Miguel,

You need to verify that msgNewsletterAction actually equals "Go" - not "go"
or "go " or " Go". Check the length to be sure it is 2 characters long. The
is not syntax issue.

bill burrows
 
Try this,

if trim(Ucase(msgNewsletterAction)) =trim(ucase("Go")) Then
code 1
else
code 2
end if
 
Hi Miqual,

Mostly in this cases it is that the string is just empty.

Nicer is by the way to make msgNewsLetterAction a Boolean instead of a
String and set it to True or False, than it can be

\\\
if msgNewsletterAction Then
code1
Else
code2
End If
///

I hope this helps?

Cor
 
try this

if msgNewsletterAction.Equals("Go") Then
code1
Else
code2
End If



Dominique
 
Hi,

i declared the variable as follows:

dim msgNewsletterAction

then i got the value from a form:

msgNewsletterAction = Request.Form("newsletterAction")

then i sent the value to an email using AspNetEmail. I readed my email and
there it was...the word "Go".

This is why this is so strange.

Thanks,
Miguel
 
Declaring msgNewsletterAction like that makes it an object. You may
need to convert it into a string type so you can evaluate it properly.
 
I think Request.Form("newsletterAction") returns a String

so try:

Dim msgNewsletterAction as String
msgNewsletterAction = Request.Form("newsletterAction")

If msgNewsletterAction.Equals("Go") Then
code1
Else
code2
End If
 
Back
Top