For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > March 2004 > IN Function?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author IN Function?
Stephen J Bement

2004-03-29, 4:32 am

Is there a VB6 equivalent to the SQL IN or EXISTS IN clause ?

--
Semper Fi,
Red

Please post to newsgroup only


Ilya Margolin

2004-03-29, 10:30 am

The closest one is SELECT CASE structure.

"Stephen J Bement" <spam@null.net> wrote in message
news:e7$2uaWFEHA.2956@tk2msftngp13.phx.gbl...
> Is there a VB6 equivalent to the SQL IN or EXISTS IN clause ?
>
> --
> Semper Fi,
> Red
>
> Please post to newsgroup only
>
>



Jan Hyde

2004-03-29, 10:30 am

"Stephen J Bement" <spam@null.net>'s wild thoughts were
released on Mon, 29 Mar 2004 03:24:53 -0500 bearing the
following fruit:

>Is there a VB6 equivalent to the SQL IN or EXISTS IN clause ?


Can you be more specific about what you're trying to
achieve?



--
Jan Hyde (MVP - Visual Basic)

If you want a picture of the future, imagine a boot
stamping on a human face - for ever.

George Orwell
[1984]

[Abolish the TV Licence - http://www.tvlicensing.biz/]

Al Reid

2004-03-29, 10:30 am

Stephen,

Here is a skeleton function that performs the "IN" Function:

Public Function IsIn(ByVal Find, ParamArray InList()) As Boolean
Dim intIndex As Integer

For intIndex = LBound(InList) To UBound(InList)
If InList(intIndex) = Find Then
IsIn = True
Exit For
End If
Next
End Function

You cannon use "IN" because it is a reserved keyword. You should also check for Type consistency between the Find Value and the
InList.

I hope this helps.

--
Al Reid

"It ain't what you don't know that gets you into trouble. It's what you know
for sure that just ain't so." --- Mark Twain

"Stephen J Bement" <spam@null.net> wrote in message news:e7$2uaWFEHA.2956@tk2msftngp13.phx.gbl...
> Is there a VB6 equivalent to the SQL IN or EXISTS IN clause ?
>
> --
> Semper Fi,
> Red
>
> Please post to newsgroup only
>
>



Jeff Johnson [MVP: VB]

2004-03-29, 12:30 pm


"Stephen J Bement" <spam@null.net> wrote in message
news:e7$2uaWFEHA.2956@tk2msftngp13.phx.gbl...

> Is there a VB6 equivalent to the SQL IN or EXISTS IN clause ?


No.

Of course anything can be simulated with enough code.


Ilya Margolin

2004-03-29, 1:30 pm

Select Case testexpression
[Case expressionlist1
[statementblock-1]]
[Case expressionlist2
[statementblock-2]]
..
..
..
[Case Else
[statementblock-n]]

End Select

Each expressionlist is a list of one or more values. If there is more than
one value in a single list, the values are separated by commas.

So the IN clause would be simulated by:

Select Case testexpression

Case list of values

[statementblock-1]]

End Select

"Stephen J Bement" <spam@null.net> wrote in message
news:e7$2uaWFEHA.2956@tk2msftngp13.phx.gbl...
> Is there a VB6 equivalent to the SQL IN or EXISTS IN clause ?
>
> --
> Semper Fi,
> Red
>
> Please post to newsgroup only
>
>



Randy Birch

2004-03-30, 10:30 pm

Allow me to add my $.02 CDN ...

Private Sub Command1_Click()

Dim a As String
Dim b As String

a = "one two three"
b = "two"
Print ExistsIn(a, b)

a = "one two three"
b = "four"
Print ExistsIn(a, b)

End Sub

Private Function ExistsIn(sData As String, sWhat As String) As Boolean

ExistsIn = UBound(Split(sData, sWhat)) > 0

End Function

'results:
> True
> False



--

Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.


"Stephen J Bement" <spam@null.net> wrote in message
news:e7$2uaWFEHA.2956@tk2msftngp13.phx.gbl...
: Is there a VB6 equivalent to the SQL IN or EXISTS IN clause ?
:
: --
: Semper Fi,
: Red
:
: Please post to newsgroup only
:
:


Rick Rothstein

2004-03-31, 12:30 am

> Allow me to add my $.02 CDN ...[color=darkred]
>
> Private Sub Command1_Click()
>
> Dim a As String
> Dim b As String
>
> a = "one two three"
> b = "two"
> Print ExistsIn(a, b)
>
> a = "one two three"
> b = "four"
> Print ExistsIn(a, b)
>
> End Sub
>
> Private Function ExistsIn(sData As String, sWhat As String) As Boolean
>
> ExistsIn = UBound(Split(sData, sWhat)) > 0
>
> End Function
>
> 'results:

Sure... steal my post.<g>

Just thought I'd mention that Split as a couple of optional arguments, the
last of which allow the delimiter to be case sensitive or insensitive (the
default) in case that matters.

Rick - MVP


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com