
VB object return wrong value in ASP page
I am using VB 4.0 32 bit to create my object. My NT 4.0 server has IIS 3.0
and ASP installed on it. I have a VB object called StringProcess with
clsIstring as the class name, and I registered the object on the NT server.
When I call the object from another VB program (lTopicKey =
Istring.IField(sTopicKeyLst, ",", ix)), I got the correct return value
(lTopicKey = 1), but when I call it from an ASP page (<%lTopicKey =
Istring.ifield(sTopicKeyLst,",",ix)%>),
I got blank as the return value (lTopicKey = blank). Could you pls let me
know what I did wrong? Thank you very much in advance.
The following is some code from my ASP page:
<%Set Istring = Server.CreateObject("StringProcess.clsIstring")
Set dbConnection = Server.CreateObject("ADODB.Connection")
dbConnection.Open "ABC"
sSQL = "SELECT TOPIC_KEY FROM TOPIC"
Set rs = dbConnection.Execute(sSQL)
sTopicKeyLst = ""
Do While Not rs.EOF%>
<script language="VBScript">
outline.AddItem "<%=rs("TOPIC_KEY")%>"
sTopicKeyLst = sTopicKeyLst & "," & <%=rs("TOPIC_KEY")%>
</script>
<%rs.MoveNext
Loop
rs.close
dbConnection.close%>
<script language="VBScript">
sTopicKeyLst = mid(sTopicKeyLst,2)
</script>
<script language="VBScript">
Sub SetTopicKey()
ix = outline.listindex + 1
msgbox ix
msgbox sTopicKeyLst
<%lTopicKey = Istring.ifield(sTopicKeyLst,",",ix)%>
msgbox "<%=lTopicKey%>" ---->>>>>>>> RESULTED IN BLANK
<%Session("TopicKey") = lTopicKey%>
end sub
</script>
The following is another VB program that calls the object:
Dim Istring As Object ' Declare variable to hold the reference.
Set Istring = CreateObject("StringProcess.clsIstring")
sTopicKeyLst = "0,1,48,49,50"
ix = 2
lTopicKey = Istring.IField(sTopicKeyLst, ",", ix) ---->>>>>>>>
RESULTED IN 1
The following is the VB object
Public Function IField(st, substr, cnt)
:
:
IField = Trim(txt)
End Function