Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP 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 May 17th, 2007, 12:49 PM
Registered User
 
Join Date: Sep 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Class not defined?

I'm trying to figure out why the first block of code doesn't work, but the second does. Are user-defined classes inaccessible inside Class_Initialize, or is there some scoping rule that requires me to put something extra in my definition?

I would have guessed that the Class_Initialize code wouldn't actually run until "Set bike = New Bicycle", at which time the compiler would have already made it past the definition of the Brake class.

Code:
<%

Class Bicycle
  Public brake

  Public Sub Class_Initialize
    Set brake = New Brake
  End Sub
End Class

Class Brake
  Public brakeType
End Class

Set bike = New Bicycle
bike.brake.brakeType = "Disc"

Response.Write bike.brake.brakeType

%>
Code:
<%

Class Bicycle
  Public brake

  Public Sub Class_Initialize

  End Sub
End Class

Class Brake
  Public brakeType
End Class

Set bike = New Bicycle
Set bike.brake = New Brake
bike.brake.brakeType = "Disc"

Response.Write bike.brake.brakeType

%>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Make sure the class defined in this file matches . Tawanda BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 September 20th, 2006 07:19 PM
how to change a CONSTANT defined in a class file? sugar PHP How-To 1 June 14th, 2006 11:49 AM
Appl-defined or Object-defined error 1004 chp Excel VBA 3 April 4th, 2006 08:12 AM
User-defined type not defined (Icecream.mdb) dloren01 BOOK: Beginning Access VBA 0 June 22nd, 2005 10:36 PM
CS1595 : 'Class' is defined in multiple places dikkjo VS.NET 2002/2003 2 June 14th, 2003 04:41 AM





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