473,378 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Questions on class definition in ASP.

Can we define events in a class when coding using VBScript in ASP?
I still have the second question, even if the answer is positive. That is
whether the two standard events of a calss module in VB, "Class_Initialize"
and "Class_Terminate", is still availabe in VBScript?
If not, then how to initialize an instance of a class automatically when it
is created?
--
Best regards,
Laser Lu
Jul 19 '05 #1
5 5401
By the way, another question, how to set a property or method as the default
property or method of a class in VBScript?
Any reply would be appreciated!

--
Best regards,
Laser Lu
"Laser Lu" <lu********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Can we define events in a class when coding using VBScript in ASP?
I still have the second question, even if the answer is positive. That is
whether the two standard events of a calss module in VB, "Class_Initialize" and "Class_Terminate", is still availabe in VBScript?
If not, then how to initialize an instance of a class automatically when it is created?
--
Best regards,
Laser Lu

Jul 19 '05 #2
Example:

<SCRIPT language="vbscript" runat="server">
Class StringMaker
Private marrayData
Private mintGrowthRate
Private mintItemCount
Private mstrJoint

Private Sub Class_Initialize()
mintGrowthRate = 100
mintItemCount = 0
mstrJoint = ""
ReDim marrayData(mintGrowthRate)
End Sub

Private Sub Class_Terminate()
Erase marrayData
End Sub

Public Property Let Joint(strData)
mstrJoint = strData & ""
End Property

Public Property Let GrowthRate(strData)
strData = Trim(strData)
If IsNumeric(strData) Then
strData = Abs(CDbl(strData))
If strData > 0 Then
mintGrowthRate = strData
ReDim marrayData(mintGrowthRate)
End If
End If
End Property

Public Sub Append(strData)
strData = Trim(strData)
If Len(strData) > 0 Then
If mintItemCount > UBound(marrayData) Then
ReDim Preserve marrayData(UBound(marrayData) + mintGrowthRate)
End If
marrayData(mintItemCount) = strData
mintItemCount = mintItemCount + 1
End If
End Sub

Public Sub Reset
Erase marrayData
Class_Initialize
End Sub

Public Function Result()
Redim Preserve marrayData(mintItemCount)
Result = Join(marrayData, mstrJoint)
End Function

Public Function ToString()
Redim Preserve marrayData(mintItemCount)
ToString = Join(marrayData, mstrJoint)
End Function
End Class
</SCRIPT>

--
dlbjr

Unambit from meager knowledge of inane others,
engender uncharted sagacity.
Jul 19 '05 #3
Deart dlbjr,
Thanks very much for your code example!
By the way, is it possible to define a default property or method in a Class
in VBScript?

--
Best regards,
Laser Lu
"dlbjr" <dl***@dontknow.doyou> wrote in message
news:RBsFb.225$Qy4.31036@typhoon01...
Example:

<SCRIPT language="vbscript" runat="server">
Class StringMaker
Private marrayData
Private mintGrowthRate
Private mintItemCount
Private mstrJoint

Private Sub Class_Initialize()
mintGrowthRate = 100
mintItemCount = 0
mstrJoint = ""
ReDim marrayData(mintGrowthRate)
End Sub

Private Sub Class_Terminate()
Erase marrayData
End Sub

Public Property Let Joint(strData)
mstrJoint = strData & ""
End Property

Public Property Let GrowthRate(strData)
strData = Trim(strData)
If IsNumeric(strData) Then
strData = Abs(CDbl(strData))
If strData > 0 Then
mintGrowthRate = strData
ReDim marrayData(mintGrowthRate)
End If
End If
End Property

Public Sub Append(strData)
strData = Trim(strData)
If Len(strData) > 0 Then
If mintItemCount > UBound(marrayData) Then
ReDim Preserve marrayData(UBound(marrayData) + mintGrowthRate)
End If
marrayData(mintItemCount) = strData
mintItemCount = mintItemCount + 1
End If
End Sub

Public Sub Reset
Erase marrayData
Class_Initialize
End Sub

Public Function Result()
Redim Preserve marrayData(mintItemCount)
Result = Join(marrayData, mstrJoint)
End Function

Public Function ToString()
Redim Preserve marrayData(mintItemCount)
ToString = Join(marrayData, mstrJoint)
End Function
End Class
</SCRIPT>

--
dlbjr

Unambit from meager knowledge of inane others,
engender uncharted sagacity.

Jul 19 '05 #4
Don't believe so. I have never really set default properties when using
vbScript classes as in VB.

-dlbjr

Discerning resolutions for the alms
Jul 19 '05 #5
yes it is.

put the word DEFAULT before the function/property word and after the
public word.

eg

PUBLIC Default FUNCTION MyFunctionName (ByVal iParam)
HTH
Al.

On Mon, 22 Dec 2003 11:38:11 +0800, "Laser Lu"
<lu********@hotmail.com> wrote:
Deart dlbjr,
Thanks very much for your code example!
By the way, is it possible to define a default property or method in a Class
in VBScript?


Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

71
by: cj | last post by:
Dear friends, I have one more questions for everyone in the newsgroup: I am preparing for an interview on UNIX/C++. Could you please identify some of the most important questions which might be...
4
by: Busin | last post by:
When a child class inherits from a base class, will the child class inherits everything of the base class, including all member variables and functions? Or is such inheritance "selective", like not...
6
by: SpOiLeR | last post by:
Hi! q1: What is C++ equivalent for: #define MY_CHAR_ARRAY_CONSTANT "My constant" if I want to define that constant in protected area of some class? I assume it has something to do with...
3
by: Tran Tuan Anh | last post by:
Dear all, I am new with C++ and very confused with some features. Really appreciate if you can explain to me some of stuffs below. I define a class: class A { static A* instance = 0; };
7
by: Victor S. | last post by:
1. What is System.Windows.Forms.VisualStyles.TextMetricsCharacterSet good for? 2. Are the Indic scripts supported? Are all supported scripts fully supported? (for printing and fine measuring)...
4
by: shamirza | last post by:
4 9 6 18.ATLAS-AJAX Note: - As an IT professional it's useful to know what the difference is between Hype and usefulness. For instance if there is a new technology coming in many programmers...
17
by: Jess | last post by:
Hello, If I have a class that has virtual but non-pure declarations, like class A{ virtual void f(); }; Then is A still an abstract class? Do I have to have "virtual void f() = 0;"...
16
by: Haskell Prelude | last post by:
Hello Friends - Can anyone answer these C questions? 1. What is the effect of making an internal (local) variable static? 2. What is the effect of making an external (non-local) variable...
77
by: Hans Schneider | last post by:
1. in the prg bellow what vars are stored on stack, heap, data segment? int i; void main() { int j; int *k = (void *)malloc(1); }
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.