With JS can use the array object is very easy to realize the function of the stack, but there is no corresponding function in the VBS, no way, only their own hands: (
If your stack does not understand please check the data structure of the relevant content. This stack class is written in reference to the C + + stack class, using the same usage. With this class you can also easily modify the queue's class:)
<%
'**********************************************
' VBS STACK Class
' Push (string) into stack
' GetTop the top element of the stack
' Pop off stack top element
' IsEmpty whether the stack is empty
' Isfull whether the stack is full (Pmax set size, can be modified by itself)
'
'**********************************************
Class Stack
Private PARR, pstring, Pmax
Private tab
Private Sub Class_Initialize ()
TAB=CHR (9)
pmax=1000 ' max capacity
End Sub
Private Sub Class_Terminate ()
If IsArray (PARR) Then
Erase PARR
End If
End Sub
Public function push (str)
If Str<> "" and InStr (Str,tab) <1 and not Isfull then
If IsArray (PARR) Then
Pstring=join (Parr,tab)
End If
Pstring=pstring & Tab & STR
Parr=split (Pstring,tab)
Push=true
Else
Push=false
End If
End Function
Public Function GetTop ()
If not IsArray (PARR) <0 Then
Gettop=null
Else
If UBound (PARR) <0 Then
Gettop=null
Else
Gettop=parr (Ubound (PARR))
End If
End If
End Function
Public Function Pop ()
If not IsArray (PARR) Then
Pop=false
Else
If Ubound (PARR) <0 Then
Pop=false
Else
Pstring=join (Parr,tab)
Pstring=left (Pstring,instrrev (Pstring,tab)-1)
Parr=split (Pstring,tab)
Pop=true
End If
End If
End Function
Public Function IsEmpty ()
If not IsArray (PARR) Then
Isempty=true
Else
If Ubound (PARR) <0 Then
Isempty=true
Else
Isempty=false
End If
End If
End Function
Public Function Isfull ()
If not IsArray (PARR) Then
Isfull=false
Else
If UBound (PARR) <pmax Then
Isfull=false
Else
Isfull=true
End If
End If
End Function
End Class
%>