
28-Jul-2006, 08:13 AM
|  | Guest | | | | | | | | | | InStr function error driving me around the bend. I am quite puzzled by the error I when this function gets called:
Runtime error "13"
Type mismatch Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/10504-instr-function-error-driving-around-bend.html
The error is triggered by the InStr function
Public Function IsNoLimit(gn As String) As Boolean
Dim gnp As String
If InStr(gn, "No Limit", vbTextCompare) > 0 Then <<< offending line of
code
IsNoLimit = True
Else
IsNoLimit = False
End If
End Function
All I want it to do is tell me if the string "No Limit" was found; InStr >0
as in gn = " 5/10 No Limit Holdem" where InStr would be 6 or "Omaha8: Limit
6/12" where InStr should be 0 as "No Limit" was not found within the search
string gn.
The help files tell me that the return data type of the InStr function is Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10504
Varient (Long). I have tried using a variable to return the InStr function to
(such as gnnl) and dimmsioning the variable to Varient and Long. The error
has always been the same which is why you see the current code attempt above.
Same error.
Anyone out there have any ideas as to why I get this error and any solutions
to it?
Much thanks for reading this somewhat lengthly post,
Bart
Do share your immediate thoughts or reactions on this issue? We value your views! Login Now! or Sign Up Today! to share your views with us.. Gurfateh! | 
28-Jul-2006, 08:13 AM
|  | Guest | | | | | | | | | | Re: InStr function error driving me around the bend. Yes, that's confusing.
The issue is that all 4 arguments of Instr() are optional, and you must
include the first (the starting position) when you include the last (the
compare type.)
Try:
If InStr(1, gn, "No Limit", vbTextCompare) > 0 Then
Or perhaps just: Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10504
IsNoLimit = (InStr(1, gn, "No Limit", vbTextCompare) = 0)
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"DaBartman" wrote in message
news:3C193C95-510C-47DD-9F1E-6D29C8D8D5FF@microsoft.com...
>I am quite puzzled by the error I when this function gets called:
> Runtime error "13"
> Type mismatch
> Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10504
> The error is triggered by the InStr function
>
> Public Function IsNoLimit(gn As String) As Boolean
>
> Dim gnp As String
>
> If InStr(gn, "No Limit", vbTextCompare) > 0 Then <<< offending line of
> code
> IsNoLimit = True
> Else
> IsNoLimit = False
> End If
>
> End Function
>
> All I want it to do is tell me if the string "No Limit" was found; InStr
> >0
> as in gn = " 5/10 No Limit Holdem" where InStr would be 6 or "Omaha8:
> Limit
> 6/12" where InStr should be 0 as "No Limit" was not found within the
> search
> string gn.
>
> The help files tell me that the return data type of the InStr function is
> Varient (Long). I have tried using a variable to return the InStr function
> to
> (such as gnnl) and dimmsioning the variable to Varient and Long. The error
> has always been the same which is why you see the current code attempt
> above.
> Same error.
>
> Anyone out there have any ideas as to why I get this error and any
> solutions
> to it?
>
> Much thanks for reading this somewhat lengthly post,
> Bart | 
28-Jul-2006, 08:13 AM
|  | Guest | | | | | | | | | | Re: InStr function error driving me around the bend. DaBartman wrote: Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10504
>I am quite puzzled by the error I when this function gets called:
>Runtime error "13"
>Type mismatch
>
>The error is triggered by the InStr function
>
>Public Function IsNoLimit(gn As String) As Boolean
>
> Dim gnp As String
>
> If InStr(gn, "No Limit", vbTextCompare) > 0 Then <<< offending line of
[...]
Try If InStr(1, gn, "No Limit", vbTextCompare) > 0 Then
If you use the compare option, you need to give the start argument.
This is perhaps one of the weirdest synatx rules in VB, so don't feel
bad  Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10504
HTH
Matthias Kläy
-- www.kcc.ch | 
28-Jul-2006, 08:13 AM
|  | Guest | | | | | | | | | | Re: InStr function error driving me around the bend. Problem solved by both of you. Thanks,
Bart
"Matthias Klaey" wrote:
> DaBartman wrote:
>
> >I am quite puzzled by the error I when this function gets called: Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10504
> >Runtime error "13"
> >Type mismatch
> >
> >The error is triggered by the InStr function
> >
> >Public Function IsNoLimit(gn As String) As Boolean
> >
> > Dim gnp As String
> >
> > If InStr(gn, "No Limit", vbTextCompare) > 0 Then <<< offending line of Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10504
> [...]
>
> Try If InStr(1, gn, "No Limit", vbTextCompare) > 0 Then
>
> If you use the compare option, you need to give the start argument.
> This is perhaps one of the weirdest synatx rules in VB, so don't feel
> bad 
>
> HTH
> Matthias Kläy
> --
> www.kcc.ch
>
> | 
28-Jul-2006, 08:13 AM
|  | Guest | | | | | | | | | | Re: InStr function error driving me around the bend. vbTextCompare is the default value in Access.
If InStr(gn,"No Limit")
This is what the line:
Option Compare Database
at the top of every module means.
(david)
"DaBartman" wrote in message
news:3C193C95-510C-47DD-9F1E-6D29C8D8D5FF@microsoft.com...
>I am quite puzzled by the error I when this function gets called:
> Runtime error "13"
> Type mismatch
>
> The error is triggered by the InStr function
>
> Public Function IsNoLimit(gn As String) As Boolean
>
> Dim gnp As String
>
> If InStr(gn, "No Limit", vbTextCompare) > 0 Then <<< offending line of
> code
> IsNoLimit = True
> Else
> IsNoLimit = False
> End If
>
> End Function Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10504
>
> All I want it to do is tell me if the string "No Limit" was found; InStr
> >0
> as in gn = " 5/10 No Limit Holdem" where InStr would be 6 or "Omaha8:
> Limit
> 6/12" where InStr should be 0 as "No Limit" was not found within the
> search
> string gn.
>
> The help files tell me that the return data type of the InStr function is
> Varient (Long). I have tried using a variable to return the InStr function
> to
> (such as gnnl) and dimmsioning the variable to Varient and Long. The error
> has always been the same which is why you see the current code attempt Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10504
> above.
> Same error.
>
> Anyone out there have any ideas as to why I get this error and any
> solutions
> to it?
>
> Much thanks for reading this somewhat lengthly post,
> Bart | 
Support Us! Become a Promoter! | | Gurfateh ji, you can become a SPN Promoter by Donating as little as $10 each month. With limited resources & high operational costs, your donations make it possible for us to deliver a quality website and spread the teachings of the Sri Guru Granth Sahib Ji, to serve & uplift humanity. Every contribution counts. Donate Generously. Gurfateh! | (View-All)
Members who have read this thread : 0
| | There are no names to display. | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Tools | Search | | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is On | | | | » Gurbani Jukebox | Listen to Gurbani while surfing SPN! | » Recent Discussions | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | » Books You Should Read... | | | |