Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / January 2007

Tip: Looking for answers? Try searching our database.

Elegant lookup?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jakob Lithner - 25 Jan 2007 14:19 GMT
I have a commaseparated string of integers (from My.Settings).
I want to check if a specified number exists in the array.
My idea was to first convert to a string array and then do some kind of
search.
I can of course add them all manually to a hashtable, but is there some kind
of direct conversion that might help?

I don't have that many values so I prefer compact code before time
optimization.
Stephany Young - 25 Jan 2007 14:29 GMT
Dim FoundIt As Boolean = (myString.IndexOf(myInteger.ToString()) >= 0)

>I have a commaseparated string of integers (from My.Settings).
> I want to check if a specified number exists in the array.
[quoted text clipped - 6 lines]
> I don't have that many values so I prefer compact code before time
> optimization.
Jakob Lithner - 25 Jan 2007 14:57 GMT
Will not work.
In this string "1,2,45,781,856" integer value 78 will be found but it should
not.

See my previous reply for a working solution.
Seems like you often refresh your brain just by telling someone else ... :-)

Thanks anyhow for your suggestion.
Jakob Lithner - 25 Jan 2007 14:31 GMT
I was just looking for methods on array and hashtable objects.
Generic List object had a convenient method that made it!

Dim ProfileArray() As String =
My.Settings.DefaultProfiles.Split(",;".ToCharArray)
Dim Profiles As New List(Of String)

Profiles.AddRange(ProfileArray)
.....
If Profiles.Contains(dr.ProfileID.ToString)) Then

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.