"if" problem. Still. Value is ok.

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

Miguel Dias Moura

Hi,

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

dim msgNewsletterAction

msgNewsletterAction = Request.Form("newsletterAction")

if msgNewsletterAction = "go" Then
Code1
Else
Code2
End If

Code2 runs everytime even when msgNewsletterAction = "go". Code1 never runs.

I sent the value of msgNewsletterAction to an email address using
AspNetEmail.
I readed my email and the value of the variable was correct and equal to
"go".

So why doesn't Code1 runs?

Thanks,
Miguel
 
Please don't open a new thread for the the issue.
i have this code line in a script in my ASP.net / VB web site:

dim msgNewsletterAction

I hope in your real application you have Option Strict On.
msgNewsletterAction = Request.Form("newsletterAction")

Try this here:

msgbox msgNewsletterAction.gettype.fullname
msgbox msgNewsletterAction.tostring.length

What is displayed?
if msgNewsletterAction = "go" Then
Code1
Else
Code2
End If


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
What if you declared msgNewsletterAction as
Dim msgNewsletterAction as String?

And by using CType(Request.Form("newsletterAction"), GetType(System.String))

Serge
 
I would check a few more things as well.

First of all, using Request.Form only grabs variables that are POSTed, not
through the QueryString, since I don't know his query string, I thought I
would just bring that up.

Second, is Option Compare Text on? (this is why I don't use strings in web
queries). Go != GO != go

Third, Listen to Armin about the option strict on, using a straight out Dim
reminds me of old asp 2.0 days... It's extra work to go through all those
conversions... That, and its just bad practice.
 
* "Miguel Dias Moura said:
i have this code line in a script in my ASP.net / VB web site:

dim msgNewsletterAction

msgNewsletterAction = Request.Form("newsletterAction")

if msgNewsletterAction = "go" Then
Code1
Else
Code2
End If

Code2 runs everytime even when msgNewsletterAction = "go". Code1 never runs.

I sent the value of msgNewsletterAction to an email address using
AspNetEmail.
I readed my email and the value of the variable was correct and equal to
"go".

So why doesn't Code1 runs?

Isn't there any other way to output the value and check it?
 
Back
Top