Hi,
I was wondering if there is a better way to do this....
This is my example....
Dim x as String()
dim y as string
dim i as string
y="tree;bush;plant;grass"
x = y.split(cchar(";"),y)
i= "house"
if i = x().? then
'do something
end if
Basically is there a way in dotnet to look into the arraylist for i without
looping through each y?
Thanks,
Brian 6 899
You can use the fact that y will start with "house;", end with ";house", or
contain ";house;". Test that with StartsWith, EndsWith, or IndexOf.
"Brian" wrote:
Hi,
I was wondering if there is a better way to do this....
This is my example....
Dim x as String()
dim y as string
dim i as string
y="tree;bush;plant;grass"
x = y.split(cchar(";"),y)
i= "house"
if i = x().? then
'do something
end if
Basically is there a way in dotnet to look into the arraylist for i without
looping through each y?
Thanks,
Brian
Once you split string using ";" convet it into Stack and then you can search
for any string. This would be faster too.
Mayur
"Brian" <bs********@community.nospamwrote in message
news:uS**************@TK2MSFTNGP04.phx.gbl...
Hi,
I was wondering if there is a better way to do this....
This is my example....
Dim x as String()
dim y as string
dim i as string
y="tree;bush;plant;grass"
x = y.split(cchar(";"),y)
i= "house"
if i = x().? then
'do something
end if
Basically is there a way in dotnet to look into the arraylist for i
without looping through each y?
Thanks,
Brian
what do you mean covert into stack?
"Mayur H Chauhan" <ma***@orioninc.comwrote in message
news:e0****************@TK2MSFTNGP03.phx.gbl...
Once you split string using ";" convet it into Stack and then you can
search for any string. This would be faster too.
Mayur
"Brian" <bs********@community.nospamwrote in message
news:uS**************@TK2MSFTNGP04.phx.gbl...
>Hi, I was wondering if there is a better way to do this.... This is my example.... Dim x as String() dim y as string dim i as string
y="tree;bush;plant;grass" x = y.split(cchar(";"),y) i= "house" if i = x().? then 'do something end if Basically is there a way in dotnet to look into the arraylist for i without looping through each y?
Thanks, Brian
I am sorry for my mistake. Instead of Stack, you can have List. Here is an
example
Dim s As String = "1;2"
Dim r = s.Split(";"c).ToList()
If r.Contains("1") = True Then
Else
End If
"Brian" <bs********@community.nospamwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
what do you mean covert into stack?
"Mayur H Chauhan" <ma***@orioninc.comwrote in message
news:e0****************@TK2MSFTNGP03.phx.gbl...
>Once you split string using ";" convet it into Stack and then you can search for any string. This would be faster too.
Mayur "Brian" <bs********@community.nospamwrote in message news:uS**************@TK2MSFTNGP04.phx.gbl...
>>Hi, I was wondering if there is a better way to do this.... This is my example.... Dim x as String() dim y as string dim i as string
y="tree;bush;plant;grass" x = y.split(cchar(";"),y) i= "house" if i = x().? then 'do something end if Basically is there a way in dotnet to look into the arraylist for i without looping through each y?
Thanks, Brian
Brian wrote:
Hi,
I was wondering if there is a better way to do this....
This is my example....
Dim x as String()
dim y as string
dim i as string
y="tree;bush;plant;grass"
x = y.split(cchar(";"),y)
i= "house"
if i = x().? then
'do something
end if
Basically is there a way in dotnet to look into the arraylist for i without
looping through each y?
Thanks,
Brian
Once you have split the data into an array, there is no way of searching
for a string in the array without looping. There are several different
ways that you can search the array, but there is no method that can do
it without looping the array.
As Mike suggested, you should search the string without splitting it.
You can use a regular expression:
If RegEx.Match("(^|;)"+RegEx.Escape("house")+"(;|$)") .Success Then
--
Göran Andersson
_____ http://www.guffa.com
Brian wrote:
I was wondering if there is a better way to do this....
y="tree;bush;plant;grass"
x = y.split(cchar(";"),y)
i= "house"
if i = x().? then
'do something
end if
Basically is there a way in dotnet to look into the arraylist for i without
looping through each y?
If you really mean "look into the /ArrayList/", then yes - ArrayList has
a Contains method:
x = New ArrayList
x.Add( tree" )
.. . .
x.Add( grass" )
Dim i as String = "house"
If x.Contains( i ) Then
. . .
End If
HTH,
Phill W. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tom Paquette |
last post by:
Hi,
Having made very good use of the ADO recordset Field indexes created by
setting the Optimize property, I am thrashing through ADO.Net literature to
identify the same functionality. Being...
|
by: Andreas Falck |
last post by:
Hi,
I ran the code below on two different versions, 4.0.14 and 4.0.16
respectively, both running RH 7.3 on intel.
In version mysql server version 4.0.14 the SELECT privelege suffices
for...
|
by: Julie |
last post by:
Due to circumstances beyond my immediate control, I've been put in charge of
getting some JavaScript code in place and operational ASAP. Normally, I'm a
C++ programmer, and previously have only...
|
by: Daniel |
last post by:
Hi there,
I recently came across an interesting option when right clicking on a
project (Right click on the project -> properties -> Configuration
Properties ->Build -> Optimize)
There is an...
|
by: Silly |
last post by:
byte Name = new byte;
uint len = (uint)Name.Length;
uint err = MyFunction(devID, out Name, out len);
When this code is run in release build with optimize code set to true, len
is evaluated to...
|
by: Reddy |
last post by:
The sql query for my datagrid returns 100, 000 records. But the datagrid
should display 20 records per page. I am using datagrid paging, but it is
taking too much time for the page to load. Is...
|
by: Steeve |
last post by:
Hi,
Is this possible to optimize this method ? It's the method than I call
most offen in my application (result of Sampling Profiling in Visual
Studio Performance report)
I use this method to...
|
by: kenneth |
last post by:
I was trying to use multiple thread to optimize my following code, but
met some problems, anyone can help me?
k are initialized.
int computePot() {
int i, j;
for( i=0; i<500; i++ ) {
for(...
|
by: timor.super |
last post by:
Hi group,
imagine I want to find number of values of a word in a string ...
Look at my code :
List<stringthingsToFind = new List<string>(new string
{"error", "values"});
MyClass myClass =...
|
by: bsagert |
last post by:
I wrote my own feed reader using feedparser.py but it takes about 14
seconds to process 7 feeds (on a windows box), which seems slow on my
DSL line. Does anyone see how I can optimize the script...
|
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: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |