我看到如下一段代码
Set System = Server.CreateObject("CNCMS.Common")
System.Login.Name = Trim(Request("username"))一般如果是system.login我是懂的,就是system实例的login属性,或者方法,但是其后面还跟了一个.name,这个我看不懂,肯请指点,我想是不是枚举类型啊,小弟对VB不熟,胡乱猜测,还望指点请问一下在vb中如何实现,还请举个实例
Set System = Server.CreateObject("CNCMS.Common")
System.Login.Name = Trim(Request("username"))一般如果是system.login我是懂的,就是system实例的login属性,或者方法,但是其后面还跟了一个.name,这个我看不懂,肯请指点,我想是不是枚举类型啊,小弟对VB不熟,胡乱猜测,还望指点请问一下在vb中如何实现,还请举个实例
<%
set bbb=server.createobject("rabbit.try")
response.write bbb.login.name
%>
这个是asp文件第一个文件,总共三个这个是第二个文件是叫try1的class
'Option Explicit
Public write_script As ScriptingContext
Public write_application As Application
Public write_request As Request
Public write_response As Response
Public write_server As Server
Public write_session As Session
Public conn As ADODB.Connection
Public requestdata As Stream Type login
name As String
End Type
Public Sub OnStartPage(MyscriptingContext As ScriptingContext)
gvIndexPage = 1
Set write_script = MyscriptingContext
Set write_application = MyscriptingContext.Application
Set write_request = MyscriptingContext.Request
Set write_response = MyscriptingContext.Response
Set write_server = MyscriptingContext.Server
Set write_session = MyscriptingContext.Session
End Sub
Public Sub getdata()
Set requestdata = New Stream
With requestdata
.Type = adTypeBinary
.Mode = 3
.Open
.Write write_request.BinaryRead(write_request.TotalBytes)
.Position = 0
End With
End Sub
Public Sub formatdate()
tempdata = requestdata.Read
stream_len = LenB(tempdata)
streamfirst = MidB(tempdata, 1, InStrB(1, tempdata, vbCrLf) - 1)
'firstream_len=
End Sub
Public Property Get login()
Set nnn = New Class1 Set login = nnn
End Property下面这个是第三个文件叫class1的class
Public Property Get name()
name = "hhh"
End Propertyvb6下测试通过
set bbb=server.createobject("rabbit.try")
response.write bbb.login.name
%>
这个是asp文件第一个文件,总共三个,代码精简一下,我引用了webclass有可能楼主没用导致错误,又要发短消息了,这个代码是做别的使的,我把工程名设置为rabbit,这个是一定能成功的代码*^_^*这个是第二个文件是叫try1的class
'Option Explicit
Public Property Get login()
Set nnn = New Class1
Set login = nnn
End Property下面这个是第三个文件叫class1的class
Public Property Get name()
name = "hhh"
End Propertyvb6下测试通过
就是你实现的是从内部取出值,但是如果要从外部赋值的话,该如何呢
<%
set system=server.createobject("cncms.common")
system.login.name="eric"(这个该如何实现呢)
Response.write system.login.name
%>
源码在此
http://61.153.48.208/eric/20050409.zip还望再指点
dim nnn,thevalue
Public Property Get login()
if IsObject(nnn) then
nnn.name=thevalue
else
Set nnn = New Class1
end if
Set login = nnn
End PropertyPublic Property let login(thevalue1)
thevalue=thevalue1
End Property第三个文件
Public Property Get name()
if isempty(name) then
name = "hhh"
else
name=thevalues
end if
End PropertyPublic Property let name(value)
thevalues=value
End Property
name = "hhh"
else
name=thevalues
end ifthevalues 要在外边声明的
Dim nnn, theValues
Public Property Get login()
If IsObject(nnn) Then
nnn.name = theValues
Else
Set nnn = New common1
End If
Set login = nnn
End PropertyPublic Property Let login(b)
theValues = b
End Property第三个文件
Dim theVal
Public Property Get name()
If IsEmpty(theVal) Then
name = "hhh"
Else
name = theVal
End If
End PropertyPublic Property Let name(a)
theVal = a
End Propertyasp文件
<%
set system=server.createobject("cncms.common")
system.login.name="aaa"
Response.write system.login.name
%>
输出结果是hhh
还请再指点一下,另外我想问一下前面说到的引用webclass library有什么用处?
Public Property Get login()
Set login = nnn
End PropertyPublic Property let login(thevalue1)
thevalue=thevalue1
'这里错了,忘了加进去第个class赋值了,不过改成这样就不能直接用我以前写那个东西了,不过满足了你赋值的要求
set nnn=new class1
nnn.name=thevalue
End Property第三个文件
Public Property Get name()
if isempty(name) then
name = "hhh"
else
name=thevalues
end if
End PropertyPublic Property let name(value)
thevalues=value
End Property