BaseGet Method of NameObjectCollectionBase

B

Billy Jacobs

I am getting an error saying:
Public Method BaseGet not found on
Type 'clsRunCollection'.

The error occurs on the call to Public Property Run. If I
change the parameter to an integer it works but I need to
retrieve the object based on it's key.


The following is my class:


Imports System.Collections.Specialized
Public Class clsRunCollection : Inherits
NameObjectCollectionBase

'Public Sub New()
' MyBase.New()
'End Sub

Public Sub Add(ByVal strKey As String, ByVal objRun
As clsRun)
MyBase.BaseAdd(strKey, objRun)
End Sub

Public ReadOnly Property RunExists(ByVal strKey As
String) As Boolean
Get
If MyBase.BaseGet(strKey) Is Nothing Then
Return False
Else
Return True
End If
End Get
End Property

Public Sub Remove(ByVal idx As Object)
If TypeName(idx) = "String" Then
MyBase.BaseRemove(idx)
Else
MyBase.BaseRemoveAt(idx)
End If
End Sub

Public ReadOnly Property Run(ByVal idx As Object) As
clsRun
Get
If TypeName(idx) = "String" Then
Return MyBase.BaseGet(CStr(idx))
Else
Return MyBase.BaseGet(idx)
End If

End Get
'Set(ByVal Value As clsRun)
' MyBase.BaseSet(vbNull, Value)
'End Set
End Property



'Count is inherited so no need to implement
End Class


Thanks,

Billy Jacobs
 
B

Billy Jacobs

Never mind I figured it out. I needed to convert the
object paramter to an int if it was not a string.

Billy Jacobs
 
J

Jay B. Harlow [MVP - Outlook]

Billy,
Glad you got it working.

FYI:
A 'better' way of doing this:
If TypeName(idx) = "String" Then

Is to use the TypeOf expression

If Typeof idx Is String Then

I say 'better' in that Typeof will return true for types derived from the
type given.

If Typeof obj Is Form Then

Will return true for all forms.

Also intellisense knows about TypeOf, you will be presented with a list of
types to check, rather then needing to type a string constant.

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top