Microsoft KB Archive/261250

= How To Expose and Use ENUMS from Visual Basic Components in Active Server Pages =

Article ID: 261250

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual InterDev 6.0 Standard Edition

-



This article was previously published under Q261250



SUMMARY
This article demonstrates how to use ENUMS that are built in Visual Basic (VB) components in the Active Server Pages (ASP) code. This method provides an alternative for .inc files with CONSTANTS.



Step-by-Step Example
 Open a new ActiveX DLL Visual Basic project. Rename Project1 to PrjEnum, and rename Class1 to ClsEnum.  Copy the following code to ClsEnum: Public Enum Salsa Mild Medium Hot End Enum

Public Function test(var As Salsa) As String Select Case var Case Mild test = &quot;Can I get a Mild Salsa&quot; Case Medium test = &quot;Can I get a Medium Salsa&quot; Case Hot test = &quot;Can I get a Hot Salsa&quot; Case Else test = &quot;No thanks!&quot; End Select End Function  Compile and make the PrjEnum.dll.  Create a blank Global.asa file, and then add the following line to the Global.asa file: Note Make sure that the file path that is referenced in the METADATA tag is correct.   Create a blank ASP page in the same folder where the Global.asa file is created, copy the following code, and then save the .asp page: <%   Dim Obj Set Obj = Server.CreateObject(&quot;prjEnum.clsEnum&quot;) response.write &quot;What kind of salsa would you like?&quot; response.write Obj.test(Hot) set obj = NOTHING %> </li> In your browser, browse to the new .asp page to check the results.</li></ol>

Additional query words: ENUM VB ASP METADATA TYPELIB TYPE

Keywords: kbhowto KB261250

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.