What is the quivelant to the SQL IN function in VB.NET? Eg. I need to know
if a string contains a specific character.
dim varwhatever as string
if varwhatever in ("5","6","9") then ...
I've been using:
if varwhatever="5" or varwhatever="6" or varwhatever="9" then ...
But there must be a better, more effecient way.
Thanks a lot. 9 1168
Instr() will return the position of a character in a string.
i.e.
dim str as string = "569"
dim i as integer = str.instr("6")
' i = 2
Thanks,
Seth Rowe
Jay wrote:
What is the quivelant to the SQL IN function in VB.NET? Eg. I need to know
if a string contains a specific character.
dim varwhatever as string
if varwhatever in ("5","6","9") then ...
I've been using:
if varwhatever="5" or varwhatever="6" or varwhatever="9" then ...
But there must be a better, more effecient way.
Thanks a lot.
Jay wrote:
What is the quivelant to the SQL IN function in VB.NET? Eg. I need to know
if a string contains a specific character.
dim varwhatever as string
if varwhatever in ("5","6","9") then ...
I've been using:
if varwhatever="5" or varwhatever="6" or varwhatever="9" then ...
But there must be a better, more effecient way.
Thanks a lot.
If INSTR("5,6,9,", varwhatever & ',') 0 Then ...
B.
I would use a Generic List.
Dim checkSet As New Generic.List(Of String)
checkSet.Add("apple")
checkSet.Add("banana")
checkSet.Add("grape")
If (checkSet.Contains("apple") = True) Then
' ... add successful IN code here...
End If
The next version of Visual Basic ("Orcas" or 9.0) will contain a new feature
called LINQ that provides SQL-like queries within the Visual Basic language.
-----
Tim Patrick - www.timaki.com
Start-to-Finish Visual Basic 2005
What is the quivelant to the SQL IN function in VB.NET? Eg. I need to
know if a string contains a specific character.
dim varwhatever as string
if varwhatever in ("5","6","9") then ...
I've been using:
if varwhatever="5" or varwhatever="6" or varwhatever="9" then ...
But there must be a better, more effecient way.
Thanks a lot.
My personal preference is to use select case.
If you use the InStr trick be aware to add delimiters both before and after
both strings. For example the code below will find "9," in "5,6,19,20"
--
Patrice
"Brian Tkatch" <Ma***********@ThePentagon.coma écrit dans le message de
news: 11**********************@k70g2000cwa.googlegroups. com...
Jay wrote:
>What is the quivelant to the SQL IN function in VB.NET? Eg. I need to know if a string contains a specific character.
dim varwhatever as string if varwhatever in ("5","6","9") then ...
I've been using:
if varwhatever="5" or varwhatever="6" or varwhatever="9" then ...
But there must be a better, more effecient way.
Thanks a lot.
If INSTR("5,6,9,", varwhatever & ',') 0 Then ...
B.
Everyone has shown good ideas. I'd thought I'd throw another suggestion
out there. How about using a Generic function?
Private Function IsIn(Of T)(ByVal Value As T, ByVal ParamArray Values()
As T) As Boolean
For Each Item As T In Values
If Item.Equals(Value) Then Return True
Next
Return False
End Function
Kelly
Jay wrote:
What is the quivelant to the SQL IN function in VB.NET? Eg. I need to
know if a string contains a specific character.
dim varwhatever as string
if varwhatever in ("5","6","9") then ...
I've been using:
if varwhatever="5" or varwhatever="6" or varwhatever="9" then ...
But there must be a better, more effecient way.
Thanks a lot.
Jay wrote:
I've been using:
if varwhatever="5" or varwhatever="6" or varwhatever="9" then ...
But there must be a better, more effecient way.
\\\
Select Case varwhatever
Case "5", "6", "9"
...do your thing here
End Select
///
--
(O)enone
Jay wrote:
What is the quivelant to the SQL IN function in VB.NET? Eg. I need to
know if a string contains a specific character.
dim varwhatever as string
if varwhatever in ("5","6","9") then ...
I've been using:
if varwhatever="5" or varwhatever="6" or varwhatever="9" then ...
But there must be a better, more effecient way.
Thanks a lot.
Jay wrote:
What is the quivelant to the SQL IN function in VB.NET? Eg. I need to
know if a string contains a specific character.
dim varwhatever as string
if varwhatever in ("5","6","9") then ...
Oops - twitchy Send finger, there ...
If you want to be Stone-Age about it
If varwhatever like "*[569]*" Then
still works perfectly well.
These days, you'd probably want a Regular Expression, something like
(air-code warning):
Dim mc As MatchCollection _
= Regex.Matches( varwhatever, "([569])" )
? mc.Groups(0).Text
HTH,
Phill W.
Patrice wrote:
My personal preference is to use select case.
If you use the InStr trick be aware to add delimiters both before and after
both strings. For example the code below will find "9," in "5,6,19,20"
--
Patrice
"Brian Tkatch" <Ma***********@ThePentagon.coma écrit dans le message de
news: 11**********************@k70g2000cwa.googlegroups. com...
Jay wrote:
What is the quivelant to the SQL IN function in VB.NET? Eg. I need to
know
if a string contains a specific character.
dim varwhatever as string
if varwhatever in ("5","6","9") then ...
I've been using:
if varwhatever="5" or varwhatever="6" or varwhatever="9" then ...
But there must be a better, more effecient way.
Thanks a lot.
If INSTR("5,6,9,", varwhatever & ',') 0 Then ...
B.
If you use the InStr trick be aware to add delimiters both before and after
both strings. For example the code below will find "9," in "5,6,19,20"
True. In my defence, i only say him use one digit. :)
B. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: domeceo |
last post by:
can anyone tell me why I cannot pass values in a setTimeout function
whenever I use this function it says "menu is undefined" after th
alert.
function imgOff(menu, num) {
if (document.images) {...
|
by: phil_gg04 |
last post by:
Dear Javascript Experts,
Opera seems to have different ideas about the visibility of Javascript
functions than other browsers. For example, if I have this code:
if (1==2) {
function...
|
by: laredotornado |
last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to
have my Javascript function execute from the BODY's "onload" method,
but if there is already an onload method defined, I would...
|
by: sushil |
last post by:
+1 #include<stdio.h>
+2 #include <stdlib.h>
+3 typedef struct
+4 {
+5 unsigned int PID;
+6 unsigned int CID;
+7 } T_ID;
+8
+9 typedef unsigned int (*T_HANDLER)(void);
+10
|
by: Olov Johansson |
last post by:
I just found out that JavaScript 1.5 (I tested this with Firefox 1.0.7
and Konqueror 3.5) has support not only for standard function
definitions, function expressions (lambdas) and Function...
|
by: Beta What |
last post by:
Hello,
I have a question about casting a function pointer. Say I want to make
a generic module (say some ADT implementation) that requires a function
pointer from the 'actual/other modules'...
|
by: f rom |
last post by:
----- Forwarded Message ----
From: Josiah Carlson <jcarlson@uci.edu>
To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org
Sent: Monday, December 4, 2006 10:03:28 PM
Subject: Re: ...
|
by: Larax |
last post by:
Best explanation of my question will be an example, look below at this
simple function:
function SetEventHandler(element)
{
// some operations on element
element.onclick =
function(event)
{
|
by: alex |
last post by:
I am so confused with these three concept,who can explained it?thanks
so much?
e.g.
var f= new Function("x", "y", "return x * y");
function f(x,y){
return x*y
}
var f=function(x,y){
|
by: VK |
last post by:
I was getting this effect N times but each time I was in rush to just
make it work, and later I coudn't recall anymore what was the original
state I was working around. This time I nailed the...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |