Article ID: 261250 - Last Review: July 1, 2004 - Revision: 3.2

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

This article was previously published under Q261250

On This Page

Expand all | Collapse all

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 Global.asa file, and then add the following line to the Global.asa file:
    <!-- METADATA TYPE="typelib" FILE="c:\MyProjects\PrjEnum\PrjEnum.dll" -->
    Note Make sure that the file path that is referenced in the METADATA tag is correct.
  6. 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("prjEnum.clsEnum")
    	response.write "What kind of salsa would you like?<BR>"
    	response.write Obj.test(Hot)
    	set obj = NOTHING
    %>
  7. In your browser, browse to the new .asp page to check the results.

APPLIES TO
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0
  • Microsoft Visual Basic 6.0 Learning Edition
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual InterDev 6.0 Standard Edition
Keywords: 
kbhowto KB261250
 

Article Translations