ASP中如何使用结构体和结构体数组呢?又如何使用集合呢?

yancey 2001-10-20 02:18:13
请教各位高手
...全文
152 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
karma 2001-10-20
  • 打赏
  • 举报
回复
here is an example:

<%@ Language="vbscript" %>
<%
'结构体
Class DumbClass

Private m_nCount
Public m_sContent

Public Property Get Number
Number = m_nCount
End Property

Public Property Let Number (nNum)
m_nCount = nNum
End Property


Public Function HelloWorld
m_sContent = "Hello World"
HelloWorld = m_sContent
End Function


Private Sub Class_Initialize
m_nCount = 0
m_sContent = ""
End Sub

End Class

Sub Main

'结构体
Dim d, s
Set d = New DumbClass
response.write "setting number...<br>"
d.Number = 12
response.write "getting number:" & d.Number & "<br>"

response.write "calling helloworld...<br>"
s = d.helloWorld
response.write "string value:" & d.m_sContent & "<br>"
'结构体数组
dim dl(3), nLoop
for nLoop = Lbound(dl) to Ubound(dl)
set dl(nLoop) = new DUmbclass

dl(nLoop).Number = nLoop
response.write "getting instance " & nLoop & "'s number:" & dl(nLoop).Number & "<br>"
next

'集合
dim col, key, keys
set col = Server.createobject("scripting.dictionary")
for nLoop = 11 to 13
set d=New DumbClass
d.Number = nLoop
key = "hello" & nLoop
set col(key) = d
next

keys = col.keys
for each key in keys
if instr(key,"hello") = 1 then
response.write "getting instance '" & key & "''s number:" & col(key).Number & "<br>"
end if
next
End Sub

Main
%>

28,405

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧