Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Com port communication 16

Status
Not open for further replies.

malforg

Technical User
May 27, 2003
3
US
Can anyone help with communicating to a COM port through Excel (on a machine that does not also have Visual Basic installed)?

I've tried downloading MSCOMM -- Excel recognizes the reference to MSComm32.ocx, but I get an error when trying to use it ("Run-time error '429': ActiveX component can't create object" ).

These are the lines of code that create the error (omitting the remainder of the subroutine). The line "Set CPort..." is what causes the error to pop up:
Code:
Sub ComPortTesting()
   Dim CPort As MSComm

   Set CPort = New MSComm 
...

This is really a two part question:

(1) Can this be done using MSComm? (Or is there some basic problem like a licensing/registry issue)

AND

(2) Is there another way to communicate with the Com port using Excel that doesn't require MSComm?

Thanks!
--Jason
 

It is totally unclear whether or not MS really wants (wanted?) to protect the MSComm itself. I would suppose they included the right to distribute the apps you create with a licensed VB6. Updating the registry just avoids having to install and uninstall the whole package on every pc you want to run your code. If MS offered the possibility to buy a license for it stand-alone (as exists for countless other ActiveX components) all of this timeconsuming fiddling wouldn't be necessary ...
 
Followed MisterC's process and can add multiple MSCOMM controls to Excel Worksheet. Presumably this will allow me to use more than 1 COM port but too lazy to test today.

Also, not to malign the knowledge of tbl, but in his Feb16 post he indicates the controls must be on a form. I found this to be true with CheapComm, but with MSCOMM I can put the control directly on a worksheet and use it. No need for a form.
 
Is it possible to get serial data from say com 1 and automatically write it to excel? I think this thread is doing the opposite?!?!
Right?
TIA,
Tammy
 
I would like to thank all of you for your comments here. I have been looking for a way to download data from a timer for years. With CheapComm it's been a piece a' cake.

PS The cheapcomm issue that arises from the openport statement always returning "true" needed a work-around, and my fix isn't elegant, but it works. In essence, I put the statement at the end of a short procedure. If the operator is notified by CheapComm that the port couldn't be opened, he/she has to be smart enough to know that the port couldn't be opened.

 
Actually, after using CheapCom for many years I have learned that MSComm is not only no more difficult to use than CheapCom , but considerably more reliable. The advantage of CheapCom is that is only consists of a few simple lines of code that can handle most serial comms. The downside is that CheapCom doesn't always work !! I have had instances where a program that has run for 2 to 3 years has begun to run erratically and I have had to switch the code over to MSComm. I personally do not believe that MSComm is subject to any restrictions at all. It was not written by Microsoft and has been included in countless (free) packages. I think that Sax Software wrote it for Microsoft as they did the version for VB.NET. My experience is that if you use the right version it always just works.

If you want to know if a port is available without getting an error message then you can use my "Get Available Ports " routine exactly as posted. Otherwise you just get a message from CheapCom that the requested port could not be opened.

Here is a simple (complete) routine that sends a bit of HEX to an engraving machine to turn it on. It requires the creation of a form with MSCOMM on it as previously described

Sub TelesisGO()
On Error GoTo ErrorMessage
If FormTelesis.MSComm1.PortOpen = 1 Then FormTelesis.MSComm1.CommPort = 0

FormTelesis.MSComm1.CommPort = 2
FormTelesis.MSComm1.Settings = "2400,N,8,1"
FormTelesis.MSComm1.PortOpen = 1
FormTelesis.MSComm1.InputLen = 0
FormTelesis.MSComm1.Handshaking = 1 'None=0,XonXoff =1,comRTS=2,comRTSXOnXOff=3
FormTelesis.MSComm1.Output = (Chr(1) & Chr(71) & Chr(2) & Chr(3) & Chr(13)) 'Telesis GO begin engraving
FormTelesis.MSComm1.PortOpen = 0
Exit Sub
ErrorMessage:
MsgBox "Can't open serial port. Ending Program"
End Sub

 
This information in this thread should allow you to read COM1 and put it into Excel. That is what I'm doing and this thread has been my sole source of information. There's a lot of code to sort through to find what you need.

Code:
   Worksheets("SerialPort").MSComm1.CommPort = 1       'Set up COM1
    Worksheets("SerialPort").MSComm1.Settings = "1200,o,7,1"
    Worksheets("SerialPort").MSComm1.InputLen = 0
    
    Worksheets("SerialPort").MSComm1.PortOpen = True
    
    Do
        DoEvents
            CRLF = Chr(13) & Chr(10)
    
    DataString = Worksheets("SerialPort").MSComm1.Input
    If (Len(DataString) > 0) Then
        gFullReport = gFullReport & DataString
        If (InStr(1, gFullReport, CRLF, vbTextCompare)) Then  'Look for end of weight
            Process_Weight (gFullReport)  'Subroutine to parse information from balance
            gFullReport = ""
        End If
    End If
    Loop Until (gListening = False)
    
    Worksheets("SerialPort").MSComm1.PortOpen = False

The DataString = Worksheets("SerialPort").MSComm1.Input line reads the data from the COM port. There is more elegant code here but this worked for me. MIght have missed something in my cut/pasting.
 
Hi,
I’m trying to get communication between a microcontroller (BasicX24) and VBA in PowerPoint. The microcontroller will be sending one byte to VBA and receiving three bytes from VBA.

In VBA I’m sending data to the serialport using CheapComm by writing the following:

nNumBytesSent = Userform1.CheapComm1.SendBinaryData(111)
Have also tried to write (1,1,1), (“1”, “1”,”1”), (“1,1,1”) and (“111”).

When I try to print the value of nNumBytesSent (Debug.Print nNumBytesSent) the immediate window writes a 0 (zero) or nothing at all, instead of 111 or 1,1,1. How can I get CheapComm to send 111?

The reason for using the function SendBinaryData instead of SendStringData is that it is important that the numbers sent are bytes since that is what the microcontroller expects to receive and sends.

VBA is quite new to me and I have tried to follow the tread “Excel Com port communication” (Thread 707-560230) but have a hard time to find a solution that’s right for me. Is there anyone out there that could help me?

Polly
 
I tried using CheapComm in a VBA for Microsoft Word instead of Excel. It seemed to work fine until after I saved the App. and then reopened it.

Anyone else tried this and had similar problems?
 
In answer to Polly's question, here is a complete routine that I use to send any string to the serial port and read in the returning response. If you want to send binary data you do have to use an array to do this. I have included my Decimal converter which makes it easier to see what you are sending. I always work with Port Monitor (freeware) running and just step through my code until I get the required response on the Port Monitor screen. It's much easier that using debug or immediate. This routine uses a defined (vertical) range on an Excel sheet where you can enter your string to be sent. In my case I had to send %01#WCSY0000**CR to my microprocessor. This was just simply entered into the cells on my test sheet individually, except for the CR. This routine can be used for testing any string, either binary or ASCII. Once you have got the required response working, then you can get rid of the excess code, but at least it helps to see what is going on.

*********************************************************
Sub SendFPOTestQueryString()

'Sends the entire string directly from the Excel sheet, stopping at the first blank line.
'Use this routine for testing new commands.

Dim PortSettings As String, BinaryResponse As String, ResponseString As String
Dim Interval As Integer, i As Integer, DataCol As Integer
Dim ArrayOut(0 To 50) As Byte 'Set the length of transmission array
Dim ArBytes(0 To 229) As Byte
Dim strFPO As String
Dim j As Integer
Dim fStartTime As Single
Dim fCurrentTime As Single
Dim bIsPortOk As Boolean
Dim nNumBytesWaiting As Integer
Dim nNumBytesReceived As Integer
Dim BytesToSend As Integer

'Routine scans the Range where the test message is stored until it comes to the first blank line
Range("TestString")(1, 1).Select
i = 1
While ActiveCell <> ""
ActiveCell.Offset(1, 0).Select

Pi = Range("TestString")(i, 1)
If i = 1 Then P1 = Pi
If i = 2 Then P2 = Pi
If i = 3 Then P3 = Pi
If i = 4 Then P4 = Pi
If i = 5 Then P5 = Pi
If i = 6 Then P6 = Pi
If i = 7 Then P7 = Pi
If i = 8 Then P8 = Pi
If i = 9 Then P9 = Pi
If i = 10 Then P10 = Pi
If i = 11 Then P11 = Pi
If i = 12 Then P12 = Pi
If i = 13 Then P13 = Pi
If i = 14 Then P14 = Pi
If i = 15 Then P15 = Pi
If i = 16 Then P16 = Pi
If i = 17 Then P17 = Pi
If i = 18 Then P18 = Pi
If i = 19 Then P19 = Pi
If i = 20 Then P20 = Pi
If i = 21 Then P21 = Pi
If i = 22 Then P22 = Pi
If i = 23 Then P23 = Pi
If i = 24 Then P24 = Pi
If i = 25 Then P25 = Pi
If i = 26 Then P26 = Pi
If i = 27 Then P27 = Pi
If i = 28 Then P28 = Pi
If i = 29 Then P29 = Pi
If i = 30 Then P30 = Pi
i = i + 1
Wend
BytesToSend = ActiveCell.Row - 2 'This is the number of characters in the test message

' Open selected serial port according to settings in PublicDeclarations
PortSettings = CStr(BaudRate & "," & Parity & "," & DataBits & "," & StopBits)
bIsPortOk = Form1.CheapComm1.OpenCommPort(ActivePort, PortSettings)
'if port can't be opened successfully, end program
If bIsPortOk = False Then
MsgBox "Can't open serial port. Ending Program"
End
End If

Form1.CheapComm1.ClearCommPort 'clear buffers

'Define array for the FPO string
ArrayOut(0) = DecimalCode(CStr(P1)) ' Use ASCII translator to convert to numbers
ArrayOut(1) = DecimalCode(CStr(P2))
ArrayOut(2) = DecimalCode(CStr(P3))
ArrayOut(3) = DecimalCode(CStr(P4))
ArrayOut(4) = DecimalCode(CStr(P5))
ArrayOut(5) = DecimalCode(CStr(P6))
ArrayOut(6) = DecimalCode(CStr(P7))
ArrayOut(7) = DecimalCode(CStr(P8))
ArrayOut(8) = DecimalCode(CStr(P9))
ArrayOut(9) = DecimalCode(CStr(P10))
ArrayOut(10) = DecimalCode(CStr(P11))
ArrayOut(11) = DecimalCode(CStr(P12))
ArrayOut(12) = DecimalCode(CStr(P13))
ArrayOut(13) = DecimalCode(CStr(P14))
ArrayOut(14) = DecimalCode(CStr(P15))
ArrayOut(15) = DecimalCode(CStr(P16))
ArrayOut(16) = DecimalCode(CStr(P17))
ArrayOut(17) = DecimalCode(CStr(P18))
ArrayOut(18) = DecimalCode(CStr(P19))
ArrayOut(19) = DecimalCode(CStr(P20))
ArrayOut(20) = DecimalCode(CStr(P21))
ArrayOut(21) = DecimalCode(CStr(P22))
ArrayOut(22) = DecimalCode(CStr(P23))
ArrayOut(23) = DecimalCode(CStr(P24))
ArrayOut(24) = DecimalCode(CStr(P25))
ArrayOut(25) = DecimalCode(CStr(P26))
ArrayOut(26) = DecimalCode(CStr(P27))
ArrayOut(27) = DecimalCode(CStr(P28))
ArrayOut(28) = DecimalCode(CStr(P29))
ArrayOut(29) = DecimalCode(CStr(P30))

nNumBytesSent = Form1.CheapComm1.SendSubArray(ArrayOut, BytesToSend) 'send FPO array
'Form1.CheapComm1.SendBinaryData (ArrayOut) 'send FPO string

'get the current time (seconds since midnight)
fStartTime = Timer

Do
'Give the program time to read the input buffer
nNumBytesWaiting = Form1.CheapComm1.GetNumBytes
fCurrentTime = Timer 'get current time
'if no reply within 2 sec, exit
If fCurrentTime - fStartTime > 2 Then
MsgBox "No Reply from Matsushita FPO PLC !", vbCritical, "Reply Error"
Form1.CheapComm1.CloseCommPort 'close Comport
End
End If
Loop Until nNumBytesWaiting > 0 'Change this value to suit number of words
'Select the number of bytes to be removed from buffer for processing
nNumBytesReceived = Form1.CheapComm1.GetBinaryData(ArBytes, 9)

Form1.CheapComm1.CloseCommPort 'close Comport

DataByte1 = ASCIIChr((ArBytes(7)))
DataByte2 = ASCIIChr((ArBytes(8)))
DataByte3 = ASCIIChr((ArBytes(9)))
DataByte4 = ASCIIChr((ArBytes(10)))

For j = 2 To 51 'Log first 50 HEX bytes received to FPO HEXData (for debugging)

ThisWorkbook.Sheets("FPOHEXData").Range("FPO.HEX.Data")(j, 1) = ASCIIChr((ArBytes(j - 2)))
Next j
'ASCIIChr



End Sub
Function DecimalCode(StringToConvert As String) As Integer

' Converts ASCII characters into Decimal
Select Case StringToConvert

Case Is = "NUL": DecimalCode = 0
Case Is = "SOH": DecimalCode = 1
Case Is = "STX": DecimalCode = 2
Case Is = "ETX": DecimalCode = 3
Case Is = "EOT": DecimalCode = 4
Case Is = "ENQ": DecimalCode = 5
Case Is = "ACK": DecimalCode = 6
Case Is = "BEL": DecimalCode = 7
Case Is = "BS": DecimalCode = 8
Case Is = "HT": DecimalCode = 9
Case Is = "NL": DecimalCode = 10
Case Is = "VT": DecimalCode = 11
Case Is = "NP": DecimalCode = 12
Case Is = "CR": DecimalCode = 13
Case Is = "SO": DecimalCode = 14
Case Is = "SI": DecimalCode = 15
Case Is = "DLE": DecimalCode = 16
Case Is = "DC1": DecimalCode = 17
Case Is = "DC2": DecimalCode = 18
Case Is = "DC3": DecimalCode = 19
Case Is = "DC4": DecimalCode = 20
Case Is = "NAK": DecimalCode = 21
Case Is = "SYN": DecimalCode = 22
Case Is = "ETB": DecimalCode = 23
Case Is = "CAN": DecimalCode = 24
Case Is = "EM": DecimalCode = 25
Case Is = "SUB": DecimalCode = 26
Case Is = "ESC": DecimalCode = 27
Case Is = "FS": DecimalCode = 28
Case Is = "GS": DecimalCode = 29
Case Is = "RS": DecimalCode = 30
Case Is = "US": DecimalCode = 31
Case Is = "SP": DecimalCode = 32
Case Is = "!": DecimalCode = 33
Case Is = """:DecimalCode=34"
Case Is = "#": DecimalCode = 35
Case Is = "$": DecimalCode = 36
Case Is = "%": DecimalCode = 37
Case Is = "&": DecimalCode = 38
Case Is = "'": DecimalCode = 39
Case Is = "(": DecimalCode = 40
Case Is = ")": DecimalCode = 41
Case Is = "*": DecimalCode = 42
Case Is = "+": DecimalCode = 43
Case Is = ",": DecimalCode = 44
Case Is = "-": DecimalCode = 45
Case Is = ".": DecimalCode = 46
Case Is = "/": DecimalCode = 47
Case Is = "0": DecimalCode = 48
Case Is = "1": DecimalCode = 49
Case Is = "2": DecimalCode = 50
Case Is = "3": DecimalCode = 51
Case Is = "4": DecimalCode = 52
Case Is = "5": DecimalCode = 53
Case Is = "6": DecimalCode = 54
Case Is = "7": DecimalCode = 55
Case Is = "8": DecimalCode = 56
Case Is = "9": DecimalCode = 57
Case Is = ":": DecimalCode = 58
Case Is = ";": DecimalCode = 59
Case Is = "<": DecimalCode = 60
Case Is = "=": DecimalCode = 61
Case Is = ">": DecimalCode = 62
Case Is = "?": DecimalCode = 63
Case Is = "@": DecimalCode = 64
Case Is = "A": DecimalCode = 65
Case Is = "B": DecimalCode = 66
Case Is = "C": DecimalCode = 67
Case Is = "D": DecimalCode = 68
Case Is = "E": DecimalCode = 69
Case Is = "F": DecimalCode = 70
Case Is = "G": DecimalCode = 71
Case Is = "H": DecimalCode = 72
Case Is = "I": DecimalCode = 73
Case Is = "J": DecimalCode = 74
Case Is = "K": DecimalCode = 75
Case Is = "L": DecimalCode = 76
Case Is = "M": DecimalCode = 77
Case Is = "N": DecimalCode = 78
Case Is = "O": DecimalCode = 79
Case Is = "P": DecimalCode = 80
Case Is = "Q": DecimalCode = 81
Case Is = "R": DecimalCode = 82
Case Is = "S": DecimalCode = 83
Case Is = "T": DecimalCode = 84
Case Is = "U": DecimalCode = 85
Case Is = "V": DecimalCode = 86
Case Is = "W": DecimalCode = 87
Case Is = "X": DecimalCode = 88
Case Is = "Y": DecimalCode = 89
Case Is = "Z": DecimalCode = 90
Case Is = "[": DecimalCode = 91
Case Is = "\": DecimalCode = 92
Case Is = "]": DecimalCode = 93
Case Is = "^": DecimalCode = 94
Case Is = "_": DecimalCode = 95
Case Is = "`": DecimalCode = 96
Case Is = "a": DecimalCode = 97
Case Is = "b": DecimalCode = 98
Case Is = "c": DecimalCode = 99
Case Is = "d": DecimalCode = 100
Case Is = "e": DecimalCode = 101
Case Is = "f": DecimalCode = 102
Case Is = "g": DecimalCode = 103
Case Is = "h": DecimalCode = 104
Case Is = "i": DecimalCode = 105
Case Is = "j": DecimalCode = 106
Case Is = "k": DecimalCode = 107
Case Is = "l": DecimalCode = 108
Case Is = "m": DecimalCode = 109
Case Is = "n": DecimalCode = 110
Case Is = "o": DecimalCode = 111
Case Is = "p": DecimalCode = 112
Case Is = "q": DecimalCode = 113
Case Is = "r": DecimalCode = 114
Case Is = "s": DecimalCode = 115
Case Is = "t": DecimalCode = 116
Case Is = "u": DecimalCode = 117
Case Is = "v": DecimalCode = 118
Case Is = "w": DecimalCode = 119
Case Is = "x": DecimalCode = 120
Case Is = "y": DecimalCode = 121
Case Is = "z": DecimalCode = 122
Case Is = "{": DecimalCode = 123
Case Is = "|": DecimalCode = 124
Case Is = "}": DecimalCode = 125
Case Is = "~": DecimalCode = 126
Case Is = "(del)": DecimalCode = 127
Case Is = " ": DecimalCode = 32

End Select
End Function
 
Thanks for the fast reply and your code. I have now got the sending part to work but not the receiving one. Can't proceed cause my trial version of Eltima port monitor ran out. I tried the Advanced Serial Port Monitor from Agg Software but it didn't work for me, cause it couldn't read the communication. Kept writing something about trial version limitation. Is there anyone that can recommened a free port monitor? Can't go on without one.
Thanks, Polly
 
No one has posted here in a while, but I thought I would chip in just the same.

I was using CheapComm but I ran into the same type of problem as Richard and Dcupper2 noted. CheapComm gets glitchy. My problem was that after working fine for a while, my OnTime events started running OK the first time through but on subsequent runs the CheapComm commands wouldn't work. I subsequently moved over to MSCOMM and was able to change my OnTime events to OnComm events. The data shows up on the worksheets much faster and I have not had any problems since I switched.

I downloaded SerialCom.zip from

It appears that you must have a license to program to MSCOMM but your end users only need it installed in order for the project to run.

This forum has been a great help in getting me started with serial port communication in Excel/VBA. I have picked up a few tidbits about MSCOMM along the way and I am quite willing to share if anyone has an interest.

Ask and you shall receive. I visit this site once or twice a week.

Greg
 
Hi

Earlier in this thread you walk us through placing cheapcomm on a form but I can't find cheapcomm and was wondering if you could tell us how to get MSCOMM working. I tried to register MSComm32.ocx as suggested earlier and that didn't work so I am at a dead end at the moment.

R4
 
Contained within the SerialCom.zip file I mentioned earlier is the MSCOMM file and instructions for registering the license. The instructions are essentially the same as described in another response, but include manually inserting the license in your registry.

I have not been able to relocate CheapComm.zip either. My advice though is to try MSCOMM again. It has more functionality and appears to be more stable. Information regarding the methods, properties etal of MSCOMM is scattered. There is some good information in the Tek-Tips VB forum. If you can find a forum on Visual FoxPro you may find some help there also.

Greg
 
Despite the various posts about the problems of registering MSCOMM and licencing it, I have never had any problem with this on any of the PCs that I have used it on. I'm not even sure that it is any different to any other ocx. Maybe the users who are having problems using it can give us some feedback as to exactly what does not work.
It is certainly true that Cheapcom works very well on 95,98,and NT, but begins to give strange results on Win2000 and higher.
If anyone needs Cheapcom I'm sure I can find a way to get it to them.
 
Ok

I've finally got MSComm working and can dial up a modem. I am currently just waiting for a fixed period then assuming connection then sending a string. The thing is the response I recieve would be a string of indeterminate length (but not that long), so can you advise how I would determine when the modem connects for sure and when the remote modem has finished sending? I'm currently looking at the comevent property but being new to this I am just blundering around.

Thanks in advance

R4
 
The default event for MSCOMM is "OnComm". Code for OnComm will be within the userform that holds MSCOMM.

.RThreshold (receive) and .SThreshold (send) are triggers for the OnComm event to run. The default value for these is 0 which means OnComm will not fire. You can set the value of either to an integer representing the number of characters that must be in the port buffer before OnComm fires. The usual number to set them to is 1. There is no relationship between .InputLen and RThreshold or .Output and SThreshold. The threshold values can be set at runtime anywhere in your code.

The .CommEvent value changes according to events at the Com Port. In the Object browser window, search for "OnComm". One of the responses will be OnComm constants. These OnComm constants are the possible values for .CommEvent and at the bottom of the window you will see the numerical values for each .CommEvent constant. comEvReceive is equal to 2 and that is probably the one you want.

Sub OpenAPort()
On Error Resume Next
ComOpenResponse = False
ComOpen.Show 'a dialog box that allows the user to select the port number. The variable "ComPortName" is set to the value of a textbox on the form.
If ComOpenResponse = False Then Exit Sub
ComForm1.MSComm1.PortOpen = False 'make sure the port is closed.
BaudRate = 9600
Parity = "n"
Bytes = 8
StopBit = 1
ComOpenParameters = BaudRate & "," & Parity & "," & Bytes & "," & StopBit
DataLength = 22
With ComForm1.MSComm1
.InputLen = DataLength 'a variable set to the lenght of the string you want removed from the port buffer.
.Settings = ComOpenParameters
.RThreshold = 0
.CommPort = ComPortName 'MSCOMM supports up to Com16
.InBufferSize = 4096
.PortOpen = True
End With
ComOpenResponse = ComForm1.MSComm1.PortOpen
If ComOpenResponse = false then
MsgBox "Com Port was not opened"
End If
Exit Sub
ErrorHandler:
MsgBox "Canceled"
End Sub

In the snippit above, OnComm will not fire because RThreshold is set to "0".
You can use an OnTime procedure to "poll the port" every so often and trap information that arrives, or you can set the RThreshold to "1" and OnComm will fire whenever information arrives at the port.
On your form that has MSCOMM on it, right click on the control and select "View code". The default event is the OnComm event.

Private Sub MSComm1_OnComm()
If ComForm1.MSComm1.CommEvent = 2 Then
Call GetTheStringFromThePort
End If
End Sub

With .RThreshold set to "1", every time a character shows up in the port buffer OnComm fires. The "If .CommEvent" line checks to see if the event that called OnComm was a receive event at the port. Since it was a receive event the GetTheStringFromThePort procedure is called.

Sub GetTheStringFromThePort()

MyString = Comform1.MSCOMM1.input 'Since we previously decided that .InputLen would be set to 22 then 22 characters will be pulled from the port.

End Sub

Lunch is over. I gottago.
 
I've not had time to really digest the answer you gave but thought I would just get on and thank you for the effort you put into it. The one question I do hav is I notice that you predetermine that InputLen is 22 characters long. How do you handle it if you don't know for sure how many digits will be returned? The reason is I want to write a script that will interrogate a system to find out how it has been programmed but the options that I will be querying can have variable lengths of information stored in them.
 
Big Thanks to MisterCfromIT for his 18 Feb 05 post. The method he described for registering the control allows it to be used in VB.NET.
 
To Ozzie,
There are two ways (at least) to handle incoming data of indeterminate length.

If you set ".InputLen = 0" then ".Input" will pull all the data out of the port buffer.

You can also use a Do-Loop and pull one character at a time until all the data has been pulled. This takes longer but if you happen to know what the end-of-string character is (CR or LF or whatever) you can stop looping when you reach it. This allows you to pull down 1 "Sentence" even though you aren't sure how long it will be.

By the way, one of the OnComm constants is "comEvRing". Sounds like it should be useful when writing code for a modem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top