DOCUMENT:Q261250 21-APR-2001 [vbwin] TITLE :HOWTO: Expose and Use ENUMS from VB Components in ASP PRODUCT :Microsoft Visual Basic for Windows PROD/VER::6.0 OPER/SYS: KEYWORDS:kbASP kbVBp600 kbVisID600 kbGrpDSASP kbDSupport kbIIS ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual Basic Enterprise Edition for Windows, version 6.0 - Microsoft Visual Basic Learning Edition for Windows, version 6.0 - Microsoft Visual Basic Professional Edition for Windows, version 6.0 - Microsoft Visual InterDev, version 6.0 ------------------------------------------------------------------------------- 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. MORE INFORMATION ================ Step-by-Step Example -------------------- 1. Open a new ActiveX DLL Visual Basic project. 2. Rename Project1 to PrjEnum, and rename Class1 to ClsEnum. 3. 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 = "Can I get a Mild Salsa" Case Medium test = "Can I get a Medium Salsa" Case Hot test = "Can I get a Hot Salsa" Case Else test = "No thanks!" End Select End Function 4. Compile and make the PrjEnum.dll. 5. Create a blank ASP page, copy the following code, and then save the .asp page: Note Make sure that the file path, which is referenced in the METADATA tag, is correct. <% Dim Obj Set Obj = Server.CreateObject("prjEnum.clsEnum") response.write "What kind of salsa would you like?
" response.write Obj.test(Hot) set obj = NOTHING %> 6. In your browser, browse to the new .asp page to check the results. Additional query words: ENUM VB ASP METADATA TYPELIB TYPE ====================================================================== Keywords : kbASP kbVBp600 kbVisID600 kbGrpDSASP kbDSupport kbIIS Technology : kbVisIDsearch kbVBSearch kbAudDeveloper kbZNotKeyword6 kbZNotKeyword2 kbVB600Search kbVBA600 kbVB600 kbVisID600 Version : :6.0 Issue type : kbhowto ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 2001.