VB icon

Serial Communication ASP

Submitted on: 1/6/2015 9:23:00 AM
By: Muhamad Kamal (from psc cd)  
Level: Advanced
User Rating: By 5 Users
Compatibility: ASP (Active Server Pages), HTML, VbScript (browser/client side)
Views: 1437
     To communicate with any device connected to com port via an activeX provided by Microsoft called MSComm (MSCOMM32.OCX).

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
' Name: Serial Communication ASP
' Description:To communicate with any device connected to com port via an activeX provided by Microsoft called MSComm (MSCOMM32.OCX).
' By: Muhamad Kamal (from psc cd)
' Inputs:I've tried using my proximity card reader connected to COM1 and was able to read data from the card once it touch the reader.
' Returns:any string feeded in by the device through COM port.
' Assumes:it needs to be beautify coz I only spent about 2-3 hours to come out with this piece of code.
' Side Effects:not tested

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
'Sub Window_OnLoad()
'	MSComm1.PortOpen =True
'end sub
Sub OpenPort()
	if Not MSComm1.PortOpen Then 
		MSComm1.PortOpen =True
		msgbox "Port already opened !", vbOKOnly, "Warning"
	end if
end sub
Sub ClosePort()
	if MSComm1.PortOpen Then 
		MSComm1.PortOpen = False
		msgbox "Port already closed !", vbOKOnly, "Warning"
	end if
end sub
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
function MSComm1_OnComm() {
	var fldWeight = frmView.txtWeight
	var strInput
	strInput = MSComm1.Input;
	window.alert (strInput); 
	fldWeight.Value == strInput;
	return false;
<OBJECT classid=clsid:648A5600-2C6E-101B-82B6-000000000014 id=MSComm1 
style="LEFT: 54px; TOP: 14px">
<PARAM NAME="_ExtentX" VALUE="1005">
<PARAM NAME="_ExtentY" VALUE="1005">
<PARAM NAME="_Version" VALUE="393216">
<PARAM NAME="CommPort" VALUE="1">
<PARAM NAME="Handshaking" VALUE="0">
<PARAM NAME="InBufferSize" VALUE="1024">
<PARAM NAME="InputLen" VALUE="0">
<PARAM NAME="NullDiscard" VALUE="0">
<PARAM NAME="OutBufferSize" VALUE="512">
<PARAM NAME="ParityReplace" VALUE="63">
<PARAM NAME="RThreshold" VALUE="14">
<PARAM NAME="BaudRate" VALUE="9600">
<PARAM NAME="ParitySetting" VALUE="0">
<PARAM NAME="DataBits" VALUE="7">
<PARAM NAME="StopBits" VALUE="0">
<PARAM NAME="SThreshold" VALUE="0">
<FORM action="" method=post id=frmView name=frmView>
<INPUT id=txtWeight name=txtWeight style="LEFT: 50px; TOP: 17px"></P>
<P> </P>
<BUTTON OnClick="OpenPort()" value="Open Port">Open COM Port</BUTTON>
<BUTTON onclick="ClosePort()" value="Close Port">Close COM Port</BUTTON>

Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

 There are no comments on this submission.

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)

To post feedback, first please login.