Classes In VBScript
This code will allow you to use classes in VBSccript versions 5.0 and higher
AI
Shrnutí AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Zdrojový kód
'Class C Class C 'Method F Sub F(msg) MsgBox msg End Sub End Class 'Using the class C Sub Main() Dim o Set o = New C o.f "my message!" 'wow a MsgBox will appear End Sub 'another example Class cEmployee 'local variables to hold property values Private mvarFullName 'local copy Private mvarAge 'local copy Private mvarRank 'local copy Private mvarSalary 'local copy Public Property Let Salary(ByVal vData) 'used when assigning a value to the property, on the left side of an assignment. mvarSalary = vData End Property Public Property Get Salary() 'used when retrieving value of a property, on the right side of an assignment. Salary = mvarSalary End Property Public Property Let Rank(ByVal vData) 'used when assigning a value to the property, on the left side of an assignment. mvarRank = vData End Property Public Property Get Rank() 'used when retrieving value of a property, on the right side of an assignment. Rank = mvarRank End Property Public Property Let Age(ByVal vData) 'used when assigning a value to the property, on the left side of an assignment. mvarAge = vData End Property Public Property Get Age() 'used when retrieving value of a property, on the right side of an assignment. Age = mvarAge End Property Public Property Let FullName(ByVal vData) 'used when assigning a value to the property, on the left side of an assignment. mvarFullName = vData End Property Public Property Get FullName() 'used when retrieving value of a property, on the right side of an assignment. FullName = mvarFullName End Property End Class Sub Main() dim o set o = new cemployee o.fullname="Alex Karpman" o.age=13 o.salary=1000000 o.rank="Big Boss" msgbox o.fullname msgbox o.age msgbox o.salary msgbox o.rank msgbox o.fullname & "-" & o.age & "-" & o.salary & "-" & o.rank end sub
Původní komentáře (3)
Obnoveno z Wayback Machine