Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 InStr and non-case sensitive
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

bobby131313
Senior Member

USA
1163 Posts

Posted - 11 September 2009 :  21:25:34  Show Profile  Visit bobby131313's Homepage  Reply with Quote
I need to find any instance of Yandex regardless of case in "AffAgent" which is the user agent. Did some Googling and came up with the following but I don't think it's working.


Dim AffAgent : AffAgent = Request.ServerVariables("HTTP_USER_AGENT") 
  If InStr(1, AffAgent, "Yandex", VBTextCompare) > 0 Then
  Do something
  End If


Does it look like it should or did I google some bum info?

Switch the order of your title tags

Edited by - bobby131313 on 11 September 2009 21:28:22

AnonJr
Moderator

United States
5768 Posts

Posted - 11 September 2009 :  22:49:32  Show Profile  Visit AnonJr's Homepage  Reply with Quote
It looks like it should... are you sure its not working? I ask only because I spent an hour today troubleshooting "missing" records that were missing because I mis-typed the date range...

As a side note, I tend to use <> 0 instead of > 0 - not that it should matter.

Edited by - AnonJr on 11 September 2009 22:49:49
Go to Top of Page

bobby131313
Senior Member

USA
1163 Posts

Posted - 11 September 2009 :  23:16:09  Show Profile  Visit bobby131313's Homepage  Reply with Quote
quote:
are you sure its not working?


No, not positive. Just figured I'd check that first. This code is to intercept ignorant bots that follow affiliate links and send them through a non-affiliate link so my stats don't get skewed. One of my sites that usually get about 400 clicks a day to this particular affiliate is now at over 1,100 for today with about 4 hours left.

Guess I'll be going through some log files tomorrow. I may just have a new ignorant bot on my hands.

Thanks for your help!

Switch the order of your title tags
Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 13 September 2009 :  23:48:43  Show Profile  Reply with Quote
You can control whether instr does a case-sensitive comparison or not

http://msdn.microsoft.com/en-us/library/wybb344c VS.85 .aspx

======
Doug G
======
Computer history and help at www.dougscode.com
Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 13 September 2009 :  23:49:34  Show Profile  Reply with Quote
quote:
Originally posted by Doug G

You can control whether instr does a case-sensitive comparison or not


http://msdn.microsoft.com/en-us/library/wybb344c(VS.85).aspx

EDIT: Hmm, snitz here doesn't seem to like the above URL, textually it's
http://msdn.microsoft.com/en-us/library/wybb344c(VS.85).aspx
copied from my firefox address bar while viewing the page.

EDIT2: Sheesh! Even inside CODE tags the url tries to become a broken link.

======
Doug G
======
Computer history and help at www.dougscode.com

Edited by - Doug G on 13 September 2009 23:52:20
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 14 September 2009 :  15:42:36  Show Profile  Visit AnonJr's Homepage  Reply with Quote
quote:
Originally posted by Doug G

You can control whether instr does a case-sensitive comparison or not

Looks like he already is since he's using vbTextCompare...
Go to Top of Page

Carefree
Advanced Member

Philippines
4224 Posts

Posted - 15 September 2009 :  01:59:23  Show Profile  Reply with Quote
An alternate approach is to do a forced lower-case comparison like this:
	if inStr(lcase(AffAgent),"yandex") then

Edited by - Carefree on 15 September 2009 01:59:45
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 15 September 2009 :  11:39:37  Show Profile  Visit AnonJr's Homepage  Reply with Quote
quote:
Originally posted by Carefree

An alternate approach is to do a forced lower-case comparison like this:
	if inStr(lcase(AffAgent),"yandex") then


Using vbTextCompare makes it a case-insensitive comparison... If you don't have some test data that has known positives and known negatives, it doesn't matter what you try as you will never know if its working.
Go to Top of Page

bobby131313
Senior Member

USA
1163 Posts

Posted - 15 September 2009 :  13:07:39  Show Profile  Visit bobby131313's Homepage  Reply with Quote
Thanks everyone. It appears my code is working. The clicks were due to IE5 downloading for "off-line" viewing. Got that addressed now after trudging through the logs.

Switch the order of your title tags
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.7 seconds. Powered By: Snitz Forums 2000 Version 3.4.07