Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

 

<%@ 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.

 

 
'=========== 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

Posted (edited)

OMG! Why didn't anyone ask me if I'm compiling the source files into a dll. I'm using Dreamweaver for god's sake. LOL [:$]

 

Please don't bother replying. I'm drowning in my noobness.

Edited by Polar Bear

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...