InStr Problems 
Author Message
 InStr Problems

Hi

I am having problems using the InStr command in an If statement. My
code is as follows:

...
Set oDoB = document.all.DateOfBirth

MsgBox InStr(oDoB.Value, "/") > 0
If InStr(oDoB.Value, "/") > 0 Then
     MsgBox "If Statement Evaluated True"
End If
...

The first MsgBox returns True, however the second never gets
processed. I am testing in I.E. 6.

I am finding this really odd - anyone got an explanation?

Thanks

Tom



Thu, 30 Jun 2005 23:01:09 GMT  
 InStr Problems
It works fine for me.  What version of VBScript are you using?

There's a possibility that your system is not properly coercing the value into a
boolean for some reason.  You might try changing the If statement to the
following:
 If CBool(InStr(oDoB.Value, "/")) > 0 Then

--
Please respond in the newsgroup so everyone may benefit.
 http://dev.remotenetworktechnology.com
 ----------
 Subscribe to Microsoft's Security Bulletins:
 http://www.microsoft.com/technet/security/bulletin/notify.asp


Quote:
> Hi

> I am having problems using the InStr command in an If statement. My
> code is as follows:

> ...
> Set oDoB = document.all.DateOfBirth

> MsgBox InStr(oDoB.Value, "/") > 0
> If InStr(oDoB.Value, "/") > 0 Then
>      MsgBox "If Statement Evaluated True"
> End If
> ...

> The first MsgBox returns True, however the second never gets
> processed. I am testing in I.E. 6.

> I am finding this really odd - anyone got an explanation?

> Thanks

> Tom



Fri, 01 Jul 2005 02:33:02 GMT  
 InStr Problems

Quote:
>It works fine for me.  What version of VBScript are you using?

I am not sure - it is part of a web page on an XP box running I.E. 6


Fri, 01 Jul 2005 03:34:27 GMT  
 InStr Problems
Should be OK then.  When you can access it, try running the following:

s = "some string containing '/' "

MsgBox InStr(s, "/") > 0
If InStr(s, "/") > 0 Then
     MsgBox "If Statement Evaluated True"
End If

I suspect that there is some other code causing an issue in the page.

--
Please respond in the newsgroup so everyone may benefit.
 http://dev.remotenetworktechnology.com
 ----------
 Subscribe to Microsoft's Security Bulletins:
 http://www.microsoft.com/technet/security/bulletin/notify.asp


Quote:
> >It works fine for me.  What version of VBScript are you using?

> I am not sure - it is part of a web page on an XP box running I.E. 6



Fri, 01 Jul 2005 05:38:03 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. PDS 7.1 BASIC IF/INSTR problem

2. InStr Problems or search for a substring in a BIIIIIG string

3. InStr problem

4. Instr Problem

5. InStr problems with large strings

6. Instr problem in VB5

7. instr problem

8. InStr Problem

9. problem with inStr

10. Problems with Instr()

11. VB6: Strange problem with InStrB() being slower than InStr()

12. Problem with inStr

 

 
Powered by phpBB® Forum Software