Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Object Referencing

Status
Not open for further replies.

brood

IS-IT--Management
Dec 24, 2005
4
NL
I have written a program that populates a collection of a vb object. Before I add a new item to that collection, I want to check that the key I'm using for that item doesn't already exist within the object (in another words, it hasn't already been assigned to another item). Is there an easy way to do this (preferrably without using error trapping)? I think Delphi used a "try" function.
 
Try IS error trapping. If the objects in the collection do not contain the key so you can
For Each .... in
if objW.Keyfield = ...
Next
then error trapping is the only way but is simple enough.

Dim lngErr
'TRY
On Error Resume Next
col.ADD ...
lngErr = Err.Number
On Error Goto 0
'CATCH
if lngerr = ...key exists error code then
...already exists
End if
Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top