473,326 Members | 2,010 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,326 software developers and data experts.

Can I use VB to contol ActiveX for .NET site?

Any suggestions on how I should handle this?

I was asked to convert a small web application that was written in classic
ASP into ASP.NET.

The original site uses some VBScript to interface with an ActiveX control,
which is contained in a CAB file.

Somehow, I have managed to use the original VBScript in a respective .NET
page, but there are several problems.

First, I need to pass into the VBScript, several .NET Session variables that
I have collected in a previous page for use by the ActiveX. I have
accomplished this by storing the variables in hidden input fields, and then
I retrieve their value from withing the VBScript. But this is such ugly
programming.

Second, in the original VBScript, the ActiveX control returns a string
(called 'Packet' in function 'citcp2_PacketReceived') and really just stores
in in a variable. I wish to pass that string on to the next page via .NET
Session, but since the last function to execute in the page is the
aforementioned 'citcp2_PacketReceived', and it's last inst instruction is to
submit, I do not know how to store the returned string into the .NET
Session. Normally, I would call a function from my C# script that would add
the string to the Session, but I don't think I can call a C# funtion form
with the VBScript.

Any suggestions on how I should handle this? Should I or can I convert the
VBScript into VB? I tried changing the language by simply cnging the
language name, but then I get an error that says "Object is expected". I
think it means that the VB script doesn't see the ActiveX control.

In the working VBScript, soSubmit() is called first, then
citcp2_Connection(address) fires and calls doSendTrade, and finally
citcp2_PacketReceived(Packet,bytes_in) fires. Here is the script:


<script LANGUAGE="vbscript" CODEPAGE="1252">
dim bTrade
bTrade = false

function doSubmit()
trade_entry_verify.citcp2.CloseSocket
trade_entry_verify.citcp2.HostAddress = "IP Adress"
trade_entry_verify.citcp2.Port = "PortNum"
Result = trade_entry_verify.citcp2.ConnectToHost
end function

Private Sub citcp2_Connection(address)
trade_entry_verify.citcp2.Send "~| Demo Screen - V7.0 -DEMO SCREE "
call doSendTrade
End Sub

Private Sub citcp2_PacketReceived(Packet,bytes_in)
trade_entry_verify.txtTrade.value = Packet
//For testing - get and store packet string in hidden label
trade_entry_verify.packetHidden.value = Packet
//For testing - retrieve and display value from hidden label in HTML
control to ensure proper output
trade_entry_verify.txtTrade2.value =
trade_entry_verify.packetHidden.value
//Session("strPacket")=Packet
//now add packet value to session
//HOW??
if bTrade then trade_entry_verify.submit
trade_entry_verify.citcp2.CloseSocket
end sub

function doSendTrade()
strTradeType = document.all.transTypeHidden.value
strOrderSpec = document.all.orderSpecHidden.value
strQty = document.all.qtyHidden.value
strMonth = document.all.monthHidden.value
strYear = document.all.yearHidden.value
strCommodity = document.all.commodityHidden.value
strCommSymbol = document.all.commoditySymbolHidden.value
strStopPrice = document.all.monthHidden.value
strLimitPrice = document.all.transTypeHidden.value
strNotes = document.all.commoditySymbolHidden.value
strSymbol = strCommSymbol & strMonth & strYear
sStr = "!NO, " & "D1003-79, " & date() & " @ " & time() & ", " &
strTradeType & ", " & strQty & ", " & strSymbol & ", DAY, " & strOrderSpec
If strOrderSpec = "MARKET" Then
sStr = sStr & ", "
ElseIf strOrderSpec = "STOP" Then
sStr = sStr & ", " & "999"
ElseIf strOrderSpec = "LIMIT" Then
sStr = sStr & ", " & "999"
End If
sStr = sStr & ", , , 0, 0, 0, 0, , Account , AcctNum|"
trade_entry_verify.txtTradeRequest.value = sStr
bTrade = true
trade_entry_verify.citcp2.Send sStr
end function
</script>


In the HTML code, the AciveX is embedded as such:


<form name="trade_entry_verify" action="trade_entry_submit.aspx"
method="post">

<asp:table id="Table1" runat="server" CellPadding="3"
CellSpacing="3" />

<p>&nbsp;</p>
<p>
<input name="Cancel" type="button" id="Cancel" value="Cancel"
onClick="history.go(-1)">
<font color="#FFFFFF">----------------------</font>
<input type="button" value="Place Order" onclick="doSubmit()">
</p>
<INPUT id="txtTradeRequest" type="text" size="123" name="Text1">
<p>
<TEXTAREA id="txtTrade" name="Textarea1" rows="2"
cols="120"></TEXTAREA>

<textarea id="txtTrade2" name="textarea" rows="2"
cols="120"></textarea>
</p>
<p>&nbsp;</p>
<OBJECT CLASSID="clsid:5220cb21-c88d-11cf-b347-00aa00a28331"
id="Microsoft_Licensed_Class_Manager_1_0"1 VIEWASTEXT>
<PARAM NAME="LPKPath" VALUE="BCITCP.lpk">
</OBJECT>
<OBJECT id="CITCP2" height="0" width="0"
classid="clsid:CAC161FD-C2F9-4F0F-95F3-A3D4E5D465CD"
codeBase="BCITCP.CAB#version=1,0,0,0" VIEWASTEXT>
<PARAM NAME="_ExtentX" VALUE="873">
<PARAM NAME="_ExtentY" VALUE="847">
</OBJECT>

<!--get and store session variables from codebehind for use in
VBScript-->
<input type="hidden" id="transTypeHidden" runat="server" >
<input type="hidden" id="qtyHidden" runat="server" >
<input type="hidden" id="yearHidden" runat="server" >
<input type="hidden" id="monthHidden" runat="server" >
<input type="hidden" id="orderSpecHidden" runat="server" >
<input type="hidden" id="commoditySymbolHidden" runat="server">
<input type="hidden" id="commodityHidden" runat="server" >
<input type="hidden" id="stopPriceHidden" runat="server" >
<input type="hidden" id="limitPriceHidden" runat="server" >
<input type="hidden" id="notesHidden" runat="server" >
<!-- get and store returned packet from CITCP2 object Doesn't work-->
<!-- <input type="text" id="packetHidden" runat="server">-->
</form>
Dec 9 '05 #1
0 1551

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

Similar topics

1
by: wang xiaoyu | last post by:
Hello: i want use activex in wxpython program,but when i use MakeActiveXClass an exception occurs. this is my source code dealing the DICOM ocx.I must note that in this program "hwtxcontrol" is...
12
by: A.M. | last post by:
Hi at all, how can I do to insert into a HTML page a file .txt stored in the same directory of the server where is the html file that must display the text file.txt? Thank you very much P.Pietro
3
by: Steve Richter | last post by:
running a simple vbscript in an .htm page that starts excel and loads the spreadsheet with the contents of a <table> ... </table> getting an "Error: ActiveX component cant create object....
1
by: Frank | last post by:
Any suggestions on how I should handle this? I was asked to convert a small web application that was written in classic ASP into ASP.NET. The original site uses some VBScript to interface with...
7
by: Jarod_24 | last post by:
I just downloaded a activex control that was written in C# and tried to view it on my PDA's Internet Explorer. At my regular PC it displayed just fine, but nothing showed up on the pda. Do...
1
by: stephen | last post by:
Hi, Can we have a tab contol on a webform just like windows application? if yes, can you please point me to the article. Thanks, Stephen
1
by: Jayender | last post by:
Hi, I have an ActiveX control (to display the Images),I have added the reference of that in my web based applicaton .and added the ocx in my tool bar , but the viewer (activex component- ocx ) is...
7
by: Artie | last post by:
Hi, Our team have a web project which includes some C# ActiveX DLLs. On some developers' PCs, the code which calls methods in the ActiveX dll is succesful - no exceptions. On other PCs, the...
1
by: Oriane | last post by:
Hi there, I've built an Asp.Net web site which launchs a ActiveX executable. When I launch this activeX from a session, with the session account, an icon associated with this activeX is...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.