Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 7th, 2004, 05:58 AM
Authorized User
 
Join Date: Jul 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default comparing strings

Hi i am having a problem with comparing two strings. I am taking
in the parameter rs("Company") and if this is empty i want to put some
text in there. I am testing it with an empty Company field and comparing
it like so:
temp1=rs("Company")
temp2=StrComp(temp1,NULL)

I have also tried it with
temp2=StrComp(temp1,"")
but each time i get nothing returned. Is there some rule about comparing a
string with an empty string?
Thanks a million!
Treasa


 
Old September 7th, 2004, 06:19 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,

  I f you want to compare with empty string, you can like..

  if test1="" then
    'NULL is not equal to ""
  end if


The StrComp function compares two strings and returns a value that represents the result of the comparison.

The StrComp function can return the following values:

If string1 < string2 - StrComp returns -1
If string1 = string2 - StrComp returns 0
If string1 > string2 - StrComp returns 1
If string1 or string2 is Null - StrComp returns Null

Syntax:
        StrComp(string1,string2[,compare])

Where compare is
Optional. Specifies the string comparison to use. Default is 0
Can have one of the following values:

0 = vbBinaryCompare - Perform a binary comparison
1 = vbTextCompare - Perform a textual comparison



 
Old September 7th, 2004, 06:23 AM
Authorized User
 
Join Date: Jul 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi thanks for replying, i have tried this and it doesn't evaluate true, even though the field company is empty.... very frustrating!

 
Old September 7th, 2004, 06:32 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default

Can you put the code here So that we can guess it clearly



(*_*)

Numan
--------------------------------------------------
Love is the most precious thing of this world. So find and grab it!
 
Old September 7th, 2004, 06:43 AM
Authorized User
 
Join Date: Jul 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi guys its okay, i got around it by getting the length of the string and make my if statement by checking if this is equal to zero, this works fine. thanks very much though!

 
Old September 11th, 2004, 09:48 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi treasacrowe,

There no such rule other than this.

When you want to check if the string variable is Empty/Null, you can do that using IsEmpty() or IsNull() functions.

When you decide to use Len(), it is better to always TRIM() that before using LEN(), so that a variable with just some blank white spaces would make you think that it is not empty.
Code:
If Len(Trim(yourvariable)) > 0 then 
    Response.write "Yes, something is there"
End If
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
comparing strings and integers pcase XSLT 2 December 1st, 2007 06:55 AM
comparing strings seymour_glass C# 5 February 6th, 2007 04:49 PM
Comparing two strings shasto100 XSLT 2 April 28th, 2006 08:10 AM
Comparing Arrays mattastic Javascript 2 January 27th, 2006 05:48 AM
Comparing DataSets. jitu ADO.NET 1 June 7th, 2004 11:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.