/    Sign up×
Community /Pin to ProfileBookmark

Inheritance/expanding a class with ASP VBScript

Hi there,

does anybody know how to implement some sort of class inheritance, with classic ASP using VB Script?

Using JScript you can use a syntax like this

[CODE]class ExampleClass extends DerivedClass[/CODE]

and ExampleClass will inherit from DerivedClass as a result.

Is there any way of doing something like this with VBScript?

Many thanks in advance,
S.

to post a comment

3 Comments(s)

Copy linkTweet thisAlerts:
@yearbassSep 22.2007 — 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.

[code=php]<%
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

%>[/code]
Copy linkTweet thisAlerts:
@SisupoikaauthorSep 22.2007 — Hi.

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.
Copy linkTweet thisAlerts:
@russellSep 22.2007 — shouldn't need to rewrite methods unless overriding them.
×

Success!

Help @Sisupoika spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...