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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String Compare Problem

Status
Not open for further replies.

bont

Programmer
Sep 7, 2000
200
0
0
US
I have a string compare problem. I am basically doing this:

MyVar = ""

.... Pulling SQL Data (from MS Access)
MyVar = SQLField (Data field is NULL)

if MyVar = &quot;&quot; then <-- Doesn't work

if len(MyVar) = 0 <--- Doesn't work

if &quot;X&quot; & MyVar = &quot;X&quot; <-- Works

Any Ideas how I can get one of the first 2 to work?

 
Hello bont,

Those are little tricks people use to convert variable type away from null. You can use properly IsNull(), IsEmpty() to your situation, such as:
Code:
If IsNull(MyVal) or IsEmpty(MyVal) Then
    'do something
End IF
regards - tsuji
 
Thanks, this works great. It is silly that it is needed.
 
If it's not implicit that a Var is a string, then you will get the problems you describe.

In this case you can use...
myVar = new String (originalVar)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top