as long as i read vbscript documentation, i never see any operator/statement for class inheritance. unfortunately there is no extends statement in vbscript.
and unfortunately (too) there is no support for inheritance in vbscript
however we still can "simulating" an inheritance by delegating derived class to extended class. but we need to rewrite all properties and methods of derived class.
PHP Code:
<%
Class DerivedClass
private m_propA
Sub Class_Initialize
m_propA = ""
End Sub
public property let PropA (data)
m_propA = data
end property
public property get PropA ()
PropA = m_propA
end property
public sub MethodA(data1,data2)
response.write "This is only sample for VBScript Inheritance"
response.write "<br>"
response.write "Your data is : <br>"
response.write "data 1 = " & data1 & ", data 2 = " & data2
response.write "<br>"
response.write "and your PropA value is: " & Me.PropA
end sub
End Class
Class ExampleClass
Private dc 'As New DerivedClass
Sub Class_Initialize
Set dc = New DerivedClass
End Sub
Sub Class_Terminate
Set dc = Nothing
End Sub
' Begin Delegate Code
public property let PropA (data)
dc.PropA = data
end property
public property get PropA ()
PropA = dc.PropA
end property
public sub MethodA (data1, data2)
dc.MethodA data1,data2
end sub
'End Delegate Code
Public Sub ExClassMethod()
Response.Write "This is from ExampleClass"
End Sub
End Class
dim ex
set ex = new ExampleClass
ex.PropA = "Testing"
ex.MethodA "Data Satu","Data Dua"
response.write "<br>"
ex.ExClassMethod
I had solved that somehow else already, but I was still looking forward to hearing of any possible more direct solutions, just out of curiosity.
Thanks anyway; it's a shame you can't do that straight away with vbscript, but at the same time am glad to have given it up long ago, at least for most things.
Bookmarks