Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help Checking VBScript Value for Not Null 2

Status
Not open for further replies.

Coder7

Programmer
Oct 29, 2002
224
US
Hi all. I've been struggling with this all morning and would really appreciate help. I return the value of company_ind to a recordset from a sql server database. Company_ind can = null, spaces or have an alphanumeric value. If the value of company_ind = spaces or is null, I want to assign E1, E2, E3 or E4 to authNav depending on what the value of sAuthCode is. If there is a value in company_ind other than spaces or null then I want to assign H1, H2, H3 or H4 to authNav depending on what the value of sAuthCode is.

Test case problems:
Company_ind is null in the db and when I response.write its value on the asp page it correctly displays 'company_ind = '. The sAuthCode = 1. Therefore the value of authNav s/b H1 but its assigning E1. Same thing happens when sAuthCode = 3: it assigns E3 but should be H3. If company_id = the string "acs" and sAuthCode = 1 then the correct value of authNave E1 is assigned.

My problem is how I'm evaluating the value of company_ind on the asp page. Thanks in advance for any help.

I've also tried <> "", not null and can't get anything to work.

Here's the scripting:

Dim authNav

If company_ind > "" Then
If sAuthCode = 1 Then
authNav = "E1"
ElseIf sAuthCode = 2 Then
authNav = "E2"
ElseIf sAuthCode = 3 Then
authNav = "E3"
ElseIf sAuthCode = 4 Then
authNav = "E4"
End If
Else
If sAuthCode = 1 Then
authNav = "H1"
ElseIf sAuthCode = 2 Then
authNav = "H2"
ElseIf sAuthCode = 3 Then
authNav = "H3"
ElseIf sAuthCode = 4 Then
authNav = "H4"
End If
End If

Response.Write("authNav = " & authNav & "<br>")

Select Case authNav
Case "E1"
do something
Case "E2"
do something
ETC
End Select
 
have you tried isNull()

___________________________________________________________________

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
Try using the IsNull() Function. It returns a True or False boolean value.

If NOT IsNull(company_ind) Then 'company isn't null
'Check what value the company is
Else
'Do NULL value working code
End If
 
or you can try IsNull() [lol]

___________________________________________________________________

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
Thank you both for the speedy responses. All is working well now thanks to your input. I went with Onpnt's suggestion since I like to eliminate negative logic whereever possible.

Thanks again!!!
 
I'm sure he's just using "If IsNull Then x Else y" instead of "If Not IsNull Then y Else x".

However, for me anyway, the language not having a function called "IsNotNull()" isn't going to keep me from using "Not IsNull()". I would always use what made the most sense if someone else was reading the code. If, for example, the point is to do something if it's not null and you're not really doing anything important if it is, then I'd definitely use "Not IsNull()" since that's really the logic of the application.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top