Polar Bear
Member
- Joined
- Aug 5, 2005
- Messages
- 15
Hi,
I created two classes, MenuItem.vb and MenuItemCollection.vb. The two files are in the same folder but for some reason the MenuItemCollection class cannot find the MenuItem class, and I get this error when I try to add the menu item to the collection.
BC30002: Type MenuItem is not defined.
Line 9: Public Sub Add(ByVal MenuItem As MenuItem)
Line 10: Me.List.Add(MenuItem)
Line 11: End Sub
The detailed compiler output shows an error on all references to MenuItem.
I created two classes, MenuItem.vb and MenuItemCollection.vb. The two files are in the same folder but for some reason the MenuItemCollection class cannot find the MenuItem class, and I get this error when I try to add the menu item to the collection.
Code:
<%@ Assembly Src="MenuItem.vb" %>
<%@ Assembly Src="MenuItemCollection.vb" %>
<script language="VB" runat="server">
Sub Page_Load
If Not IsPostBack Then
Dim MenuItems = New MenuItemCollection()
MenuItems.Add(New MenuItem(1, "Test"))
End If
End Sub
BC30002: Type MenuItem is not defined.
Line 9: Public Sub Add(ByVal MenuItem As MenuItem)
Line 10: Me.List.Add(MenuItem)
Line 11: End Sub
The detailed compiler output shows an error on all references to MenuItem.
Code:
=========== MenuItem.vb==============
Public Class MenuItem
Private m_MenuID As Integer
Private m_Title As String
Public Sub New()
End Sub
Public Sub New(ByVal MenuID As Integer, ByVal Title As String)
With Me
.m_MenuID = MenuID
.m_Title = Title
End With
End Sub
Public Property MenuID() As Integer
Get
Return m_MenuID
End Get
Set(ByVal Value As Integer)
m_MenuID = Value
End Set
End Property
Public Property Title() As String
Get
Return m_Title
End Get
Set(ByVal Value As String)
m_Title = Value
End Set
End Property
End Class
=========== MenuItemCollection.vb==============
Imports System.Collections
Public Class MenuItemCollection
Inherits CollectionBase
Public Sub New()
End Sub
Public Sub Add(ByVal MenuItem As MenuItem)
Me.List.Add(MenuItem)
End Sub
Public Function Contains(ByVal MenuItem As MenuItem) As Boolean
Return Me.List.Contains(MenuItem)
End Function
Public Function IndexOf(ByVal MenuItem As MenuItem) As Integer
Return Me.List.IndexOf(MenuItem)
End Function
Public Sub Insert(ByVal index As Integer, ByVal MenuItem As MenuItem)
Me.List.Insert(index, MenuItem)
End Sub
Default Public Property Item(ByVal Index As Integer) As MenuItem
Get
Return CType(Me.List.Item(Index), MenuItem)
End Get
Set(ByVal Value As MenuItem)
Me.List(Index) = Value
End Set
End Property
Public Sub Remove(ByVal MenuItem As MenuItem)
Me.List.Remove(MenuItem)
End Sub
End Class