views:

82

answers:

3

Is there anyway to do something like classes in vbscript. I ain't so good in classic ASP. Or does anybody have a C# vbscript conversion FAQ. My problem is that I must consume a webservice in classic ASP and the returntype is an array of a class. In asp.net with C# it's a piece of cake, because I know how to do it, but how do you do it in classic ASP?

A: 

You can create classes in VBScript, much the same way you might in VB (with the obviously more limited syntax of VBScript).

Have a look at the Downloads page for the Wrox VBScript reference (which is an excellent reference, BTW). In it, you'll find source code for a complete chapter's worth of VBScript classes and examples.

Specifically, you'll want Chapter 8.

Phil.Wheeler
+3  A: 

You can, but just bear in mind that there is no inheritance.

within your class, the following are the contructor and destructors.

Class_Initialize()
Class_Terminate()

See http://msdn.microsoft.com/en-us/library/4ah5852c%28VS.85%29.aspx

Christopher Mahan
A: 

I did something like this to simulate properties, but they are functions. I'm not sure how to do properties in vbscript. Help anyone?

Class Fubar


 Private m_var 

  Public Function set_one_type(stringtype)
 m_var = stringtype 
  End Function

  Public Function get_one_type 
 get_one_type = m_var 
  End Function 



  Public Function myBox(strMsg)  
 myBox = "Hej " & strMsg
  End Function
End Class

And you use it like this:

Set myFubar = new Fubar
myFubar.set_one_type("Volvo") 

Response.Write(myFubar.get_one_type()) 
poo
This is actually further information to your question rather than an answer. Please edit your question when you want to provide more info.
AnthonyWJones