The MSComm control uses the "return quickly" feature of the Windows COM port
driver. If you use RDP 5.2 for port redirection, the status of the "return
quickly" feature is set to pending. This setting affects the functionality of the MSComm control.
Note Make sure that the COM1 port is enabled on your local computer
and on the remote computer. Also, verify that you have RDP 5.2 on your local
computer. To obtain RDP 5.2, visit the following Microsoft Web site:
Connect a modem to the COM1 port of your local
Restart your local computer.
Install the correct driver for your modem.
Connect to a remote computer that is running Windows
Server 2003 through Microsoft Terminal Services by using the RDP 5.2 protocol.
To do this, follow these steps:
Click Start, click
Run, type mstsc, and then click
OK. The Remote Desktop Connection dialog box
In the Computer box, type the Internet
Protocol (IP) address of the terminal server that is running Windows Server
2003 and that you want to connect to, and then click
Click the Local Resources
In the Local devices section, make
sure that the Serial ports check box is selected, and then
click Connect. The Remote Desktop Connection Security
Warning dialog box appears.
Click OK. The Log On to
Windows dialog box appears.
In the User name box, type your user
In the Password box, type your
password, and then click OK to connect to the terminal
On drive C of the terminal server, create a text file. Name
the text file Testfile.txt.
Type Hello World in the Testfile.txt
Save the Testfile.txt file, and then close the
Start Visual Basic 6.0 on the terminal server.
On the File menu, click New
Project. The New Project dialog box
Click Standard EXE, and then click
OK. By default, a form that is named Form1 is
On the Project menu, click
References. The References – Project1 dialog
Under Available References, click to
select the Microsoft Scripting Runtime library, and then click
On the Project menu, click
Components. The Components dialog box
Click the Controls tab.
On the Controls tab, click to select the
Microsoft Comm Control 6.0 control, and then click
Add an MSComm control and a command button to the Form1 form. By default, the
MSComm1 MSComm control and the Command1 command button are
added to the form.
On the View menu, click
Code to view the code window.
In the code window, add the following code.
Const HANDSHAKING_NONE = 0
Const INPUTMODE_TEXT = 0
Private Sub Command1_Click()
Dim FilePath As String
Dim FileSystem As FileSystemObject
Dim oFile As Object
'Make sure that you have the Testfile.txt file on drive C of your computer.
FilePath = "C:\Testfile.txt"
'Create a new FileSystemObject object, and then open the Testfile.txt file for reading.
Set FileSystem = New FileSystemObject
Set oFile = FileSystem.OpenTextFile(FilePath, ForReading)
'Specify the communication port for the MSComm control.
MSComm1.CommPort = 1
Call ReadWrite(oFile, MSComm1)
Sub ReadWrite(File As Object, MyPort As MSComm)
'This procedure performs the following tasks:
'1.Configures and opens the MyPort port.
'2.Reads the contents of the File object, and then stores the data in a buffer that is named OutBuffer.
'3.Writes the data from the OutBuffer buffer to the MyPort port.
'4.Reads the data from the MyPort port to a buffer that is named InBuffer.
Dim OutBuffer As Variant
Dim InBuffer As Variant
MyPort.Settings = "57600,N,8,1"
' Configure the port.
MyPort.Handshaking = HANDSHAKING_NONE
MyPort.EOFEnable = False
MyPort.RThreshold = 0
MyPort.SThreshold = 0
MyPort.InputMode = INPUTMODE_TEXT
' Specify the buffer size.
MyPort.InBufferSize = 1024
' Open the port.
MyPort.PortOpen = True
' Read the buffer and transmit each line over the COM port.
'Read each line of data from the file.
OutBuffer = File.ReadLine
' Configure the port to read the whole buffer.
MyPort.InputLen = 0
' Write the data, and then read it.
MyPort.Output = OutBuffer
InBuffer = MyPort.Input
Loop While (File.AtEndOfStream = False)
' Close the port.
MyPort.PortOpen = False
On the Run menu, click
Start. The Form1 form appears.
Click Command1. You receive the error
message that is mentioned in the "Symptoms" section.