keitsi Posted April 4, 2004 Posted April 4, 2004 (edited) Currently I am using this function (LOL) Public Function ExistsInColl(ByRef col As Collection, ByVal Index As String) As Boolean On Error GoTo ErrNotInColl Dim tmp tmp = col(Index) Return True ErrNotInColl: On Error GoTo 0 Return False End Function Errors seems to lag my .NET (at least while not running straight from .exe) and I'm finding this kinda annoying... anyone happen to know a better way? :D Yea, should use Try..catch. Just ported it from VB6, which does not have a way to get around this that I know of. Just to mention.. also something similar to collection should be okay. I mean something more advanced that arrays but not as heavyweight as DS / Xml / etc objects. Edited April 4, 2004 by keitsi Quote BS - Beer Specialist
Administrators PlausiblyDamp Posted April 4, 2004 Administrators Posted April 4, 2004 If you use a hashtable rather than a collection it has two methods - ContainsValue and ContainsKey -these may be a bit easier. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
keitsi Posted April 4, 2004 Author Posted April 4, 2004 nice Great, thanks! Quote BS - Beer Specialist
CattleRustler Posted April 5, 2004 Posted April 5, 2004 regardless of just porting over from vb6, why would you use an error trap to test a condition? Use try-catch-end try to protect yourself from unhandled errors stopping your app - use a condition test to find your item or not, regardless of the vehicle you use to store it (ie Collection, Hashtable, array, etc) Quote mod2software Home of the VB.NET Class Builder Utility - Demo and Full versions available now!
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.