Wrox Programmer Forums
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 22nd, 2006, 10:56 AM
Registered User
 
Join Date: Oct 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Class Nesting Weirdness??


I have the following skeletal routine:

   Module Module1

      Public Class ClassA

         Public Sub RoutineA()

            Dim Param As Integer

            Call RoutineB(Param)

         End Sub

         Public Class ClassB

            Public Sub RoutineB(ByRef Glob As Integer)
               Glob = 3
            End Sub

         End Class ' End ClassB

      End Class ' End ClassA

   End Module


The Call SubRoutineB(Param) flags an error "name SubroutineB not declared"!
From what I have read, the "public" declaration should have made all the routine names available globally. Am I missing something or is there something about nesting classes that I do not understand?

All the best,
              HotBlue.




 
Old November 8th, 2006, 11:46 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by HotBlue


I have the following skeletal routine:

Module Module1

     Public Class ClassA

         Public Sub RoutineA()

            Dim Param As Integer

            Call RoutineB(Param)

         End Sub

         Public Class ClassB

            Public Sub RoutineB(ByRef Glob As Integer)
             Glob = 3
            End Sub

         End Class ' End ClassB

     End Class ' End ClassA

End Module


The Call SubRoutineB(Param) flags an error "name SubroutineB not declared"!
From what I have read, the "public" declaration should have made all the routine names available globally. Am I missing something or is there something about nesting classes that I do not understand?

All the best,
             HotBlue.
As far as I can see, you haven't declared a method named SubroutineB. You have one named RoutineB, and that might be the one you intended to be calling. The error you are getting actually tells you the same thing.

Woody Z http://www.learntoprogramnow.com
 
Old November 8th, 2006, 01:25 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

You cannot call that routine until the class is instantiated, can you?

Or don't you need to declare the class as Shared or Static to have its members always available?

Sorry for the vagueness—don’t actually want to go look it up if this or what Woody posted helps...
 
Old November 8th, 2006, 03:22 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Brian is absolutely right - if what you intend is to call RoutineB you will need to instantiate an instance of ClassB first and call that method on that class. The nesting is not the problem.

Woody Z http://www.learntoprogramnow.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Nesting Repeater controls Stricken ASP.NET 2.0 Basics 0 February 2nd, 2007 08:31 AM
Nesting queries??? giffordpinchot Access 0 September 20th, 2006 09:58 AM
Simple Nesting Loop PommyTom XSLT 2 June 9th, 2006 02:16 AM
Nesting ADO recordsets yossarian Pro VB Databases 1 January 12th, 2005 06:28 PM
Subreports nesting svenvandevelde Crystal Reports 2 February 4th, 2004 12:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.