Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by keitsi
BS - Beer Specialist
Posted
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)

mod2software

Home of the VB.NET Class Builder Utility - Demo and Full versions available now!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...