Results 1 to 4 of 4

Thread: Compare two strings

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Location
    Sussex, England
    Posts
    45
    Can someone tell me what the correct way of writing this would be, it's driving me nuts :

    If rs("nodename") NOT = "Home" Then

    Thanks in advance
    Ian.

  2. #2
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    If rs("nodename") NOT = "Home" Then

    should be:
    Code:
    if UCase(rs.Fields("nodename")) <> "HOME" Then
    the above guarantees that the case issue is resolved, (and i'm assuming it's a field)

    HTH
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Code:
    If Not rs("nodename") = "Home" Then
    'or
    If rs("nodename") <> "Home Then
    
    'when you read data from a DB the string might return extra
    'spaces or it might contain null values which VB won't
    'recognize as a string so you should type it in the
    'following manner instead
    
    If Trim$(rs("nodename") & "") <> "Home" Then
    Good luck!

  4. #4
    Guest

    personally i like to do it this way...

    with a bang(!)

    Code:
    If Trim$(rs!nodename) <> "Home" Then

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width