|
-
January 7th, 2000, 06:16 PM
#1
Collections And UDTs
Hello,
Can someone please tell me if it is possible to add a User Defined Type to a collection in Visual Basic 5? From what I've read in the Books online, this is possible, but I can't seem to get it to compile correctly. The compiler keeps saying "ByRef Argument Type Mismatch" at the line where I am trying to .Add to the collection.
For example:
private Sub AddTUFEditError(nseverity as Long, nField as Long, strMessage as string)
Dim theError as TUFEditError
theError.Severity = nseverity
theError.FieldNum = nField
theError.ErrorMessage = strMessage
TUFEditErrorCollection.Add theError 'ERR!
End Sub
Please forgive me if this is a stupid question, but I can't figure out how to make this work, and this one detail is holding my project up.
Please if anyone knows of a way around this problem, post the solution or e-mail me.
Thanks,
John Holifield
[email protected]
[email protected]
-
January 9th, 2000, 06:28 PM
#2
Re: Collections And UDTs
No, you cannot do that. You have 2 possible solutions:
1. Instead of collection, use array with your UDT
2. Replace your UDT with a class, e.g.
'------------------------------
' class TUFEditError
Option Explicit
Public Severity As Long
Public FieldNum As Long
Public ErrorMessage As String
'------------------------------
You'll have to add 1 line in your Sub AddTUFEditError:
Dim theError As TUFEditError
Set theError = New TUFEditError ' create instance of the TUFEditError class
theError.Severity = nseverity
theError.FieldNum = nField
theError.ErrorMessage = strMessage
TUFEditErrorCollection.Add theError
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|