Community discussion forum

Com Ports and the MSComm Control

This is a comment thread discussing Com Ports and the MSComm Control
  • 10 years ago

    This thread is for discussions of Com Ports and the MSComm Control.

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 6 years ago

    hi..there...


    I would like to ask you the following questions.


    1. If I open my Com port, does it mean I am always listening to incoming data from that com port?
    2. If it does not keep listening, how do I do the polling in my program so that it will keep listening to incoming data from that com port?


    Hope you would like to answer my questions....


    Thank You very much


    Nelly

  • 6 years ago

    As long as PortOpen is TRUE, the OnComm Event will fire if there is incomming data.

  • 6 years ago

    Can we use mscomm control to read synchronous binary data. If yes, please tell me how?


    Thank you.

  • 6 years ago

    Hello,


    How can receive the numbers pressed by anyone while I am talking with him/her via telephone. I think this is the way PABX works.


    My compiler is showing syntax error with the following code-
    txtOutput.Text = txtOutput.Text & StrConv(MSComm1.Input, vbUnicode)


    Please help...


    Anup

  • 6 years ago

    Hi,


    Hopefully there's a simple solution to this one, but I'm pulling my hair out right now, coz I've tried everyway I can think of ....



    Please forgive me if I'm overlooking the obvious, but though I'm an experienced programmer, I am very new to VB!


    I am trying to write an application to emulate a thermal printer to allow printing 'through' a PC. The received data includes nulls/zeros, mainly as part of command properties, which I need the app to recognise.


    I have tried to receive the data as text (comInputModeText) but as null is an empty string, that doesn't work! I have tried receiving the data numerically (comInputModeBinary) but as soon as I try to run the app with 'NullDiscard' as false it hangs, seemingly receiving infinate nulls/zeros, long after the input data has ceased. The program does not hang if I set 'NullDiscard' to true, but of course then I don't get my nulls!!


    Please Help!! ... anyone!!


    Cheers,


    Mark H

  • 6 years ago

    I tried using your comport example but it didn't work on windows 98.  is there any supporting DLL's or components I need to attach to my project.

  • 6 years ago

    Can i transfer a file to my friend with whom i am talking on a phone by holding on the connection using the mscomm control?
    (this refers to use of voiceview at-commands). please help me out.

  • 6 years ago

    how can i get the numbers pressed on the telephone using mscomm control, using the same telephone line with modem and telephone?

  • 6 years ago

    OK guys, don't all rush to help ... sussed it anyway!!


    Anyone experiencing the same problem, use comInputModeBinary reception mode and receive the entire buffter into a byte array, then get the size of the array using UBound (+1 to include the first byte stored in the zero element) and write your decoding routine within a for next loop to work through each received byte. (Did that make any sense?? )




    Mark H

  • 6 years ago

    Hi Ashsoliman,


    I'm having that problem too, actually with Win Me, but I suspect it doesn't work with any non-XP/2000/NT PCs.


    I have based a port detection part of a project I'm working on around this method, and it worked fine until I came to install the final program on a Win Me system.


    Have you found a solution yet ??


    I'll let you know if I find one.


    Cheers
    Mark

  • 6 years ago

    Dear All,


    I got some problem when I try to capture data using the onComm1.commEvent


         Case comEvReceive        
           ' receive log here
           inBuffer = inBuffer & MSComm1.Input
           Debug.Print MSComm1.Input


    I have to put the break point infront of the MsComm1_OnComm() inorder to have it fire.


    my configure of MsComm1 is:
    Private Sub Form_Load()
       With MSComm1
             .CommPort = 1
             .Handshaking = comRTSXOnXOff
             .RThreshold = 1
             .RTSEnable = True
             .Settings = "9600,n,8,1"
             .SThreshold = 1
             .PortOpen = True
             .EOFEnable = True
             .InputMode = comInputModeText
             .InputLen = 0
       End With
    End Sub


    According to the posting above it should be working fine.
    But for my case it was not .


    Help,
    Many Thanks

  • 6 years ago

    Hi,
        Please help me regarding the usage of the MSComm control.Iam able to recieve messages but not able to transmit messages.I can clearly hear the other parties voice but they r not able to hear me.

  • 6 years ago



    i have a copy (from legit source) of mscomm ocx and have added to available controls, but vb 6 does not recognise mscomm (says it need an object declaration) - the downloaded code from here causes error - any thoughts?


    kevin

  • 6 years ago

    How do i create a marquee script for an email signature....ive seen it on someones email they sent me and it looks so cool, i am on a works network p.c so i dont know if i am able to do it or not, please supply the code and instructions if poss


    kind regards


    chris

  • 6 years ago

    Kevin,


    Have you found a solution to this yet?  I am having the same problem (error 424).


    I would appreciate any insight you may have.


    Terry

  • 6 years ago

    no real answer, I have used alternate means to read the com port that works  (sort of)


    kevin

  • 6 years ago

    Hey Kevin,


    If you don't mind sharing, what was your workaround.


    Terry

  • 6 years ago

    Hi,


    I faced the same prob with you. can some one offer help!!


    by the way, I'm doing the sms thing I'm can send out the msg but can't receive the msg.  why ah?

  • 6 years ago

    Halo,


    I can fire the commevent but not always...that's make my prg not consistant.. any help

  • 6 years ago

    As I can know when they answered I telephone using the MSComm  


    my code is :




    Private Sub InicializarModem()


    With msModem
            .CommPort = 3
            .Handshaking = comRTSXOnXOff
            .RThreshold = 1
            .RTSEnable = True
            .Settings = "9600,n,8,1"
            .SThreshold = 1
            .EOFEnable = True
            .InputMode = comInputModeText
            .InputLen = 0
            .PortOpen = True
            .Output = "ATZ"
            .PortOpen = False
    End With


    end sub



    Private Sub CallNumber(Byval sOutput as String)
       With msModem
            .PortOpen = True
            .Output = "ATDT" & sOutput & vbCrLf
       End With
    end sub


    Private Sub msModem_OnComm()
    'Occurs when there's a change in the modem signal
    Dim InBuff As String


    Select Case msModem.CommEvent
       'Case comEventBreak : A Break was received from the line : not required
       'The next three cases are timeout values, no longer detected in Win32 systems
       'Case comEventCDTO
       'Case comEventCTSTO
       'Case comEventDSRTO
       'Case comEventFrame
       
       Case comEventOverrun ' Data Lost during transfer
           MsgBox "Some Data was lost during transfer."
       Case comEventRxOver  ' Receive buffer overflow.
           'taken care in another sub in form2
       Case comEventRxParity   ' Parity Error.
           MsgBox "Parity Error !"
       Case comEventTxFull  ' Transmit buffer full.
           'taken care in another module in form2
       Case comEvCD   ' Change in the CD line.
       'Used to detect connection state :
       'Though it's taken care by using ATX4 modem command, it's required
       'for AT non compatible modems
           If msModem.CDHolding = True Then
               'connected
               Connected = True
           Else
               'Disconnected
               Connected = False
           End If
         Case comEvReceive 'Received RThreshold no. of chars.
            'Use strconv to convert the binary data got from modem
            'InBuff = StrConv(msModem.Input, vbUnicode)
            InBuff = msModem.Input
            Call ScanCom(InBuff)
         Case comEvSend 'There are SThreshold number of characters in the
                        'transmit buffer.(this should never occur as there's form2, but, in case)
            Do While msModem.OutBufferCount > 0
               DoEvents
            Loop


      End Select
     
    End Sub



    Private Sub ScanCom(ByVal instring As String)
    ' This routine will work on data (instring) received from the Com Port.
    Dim X As Integer 'position being read from instring
    Dim Y As String 'data in position being read (X)


    If Connected = False Then
    ' Not connected...so data may be modem responce.
    ' Work on data (instring) received between vbcrlf's:
       For X = 1 To (Len(instring) + 1)
           Y = Mid$(instring, X, 1)
           If Y = Chr$(13) Then
               Y = ""
               '"MessageHandler" is where to do the processing on
               ' the packet after it is fully parsed here:
               Call MessageHandler(UseString)
               UseString = ""
           End If
           UseString = UseString & Y
       Next X


    Else
       'Connected=true. So parse data.
       'Data begins with <modem> , ends with <xodem> + chr$(13)
       For X = 1 To (Len(instring) + 1)
           Y = Mid$(instring, X, 1)
           If Y = Chr$(13) Then
               If Len(UseString) > 11 And Right(UseString, 7) = "<xodem>" Then
                   Y = ""
                   Call MessageHandler(UseString)
                   'Process the data
                   UseString = ""
               End If
           End If
           UseString = UseString & Y
       Next X
    End If
    End Sub


    Private Sub MessageHandler(InBuff As String)
               
    If IsVacio(InBuff) Then Exit Sub
    If InStr(1, InBuff, "=") <> 0 Then Exit Sub
    If Len(InBuff) <= 1 Then Exit Sub


    InBuff = Right(InBuff, Len(InBuff) - 1)


    'Modem responses


    'Occurs when a command sent to modem is accepted
    If InStr(InBuff, "OK") Then


       InBuff = ""
       Exit Sub
    End If


    'if command "ATX4" has been sent to modem,
    'inbuff will be "CONNECT #####" where ##### = speed
    'connected to remote comp
    If InStr(InBuff, "CONNECT") Then
       Connected = True
       lblLlamada(3) = "CONECTADO"
       strHoraInicioLlamada = Format(Time, "HH:MMS")
       InBuff = ""
       Exit Sub
    End If
     
     
    If InStr(InBuff, "CARRIER") Then
       
       If MsgBox("No se recibio respuesta del telefono marcado, desea capturar alguna observación ?", vbYesNo + vbQuestion, "Automarcado") = vbYes Then
           tmpObs = InputBox("Capture aqui las observaciones de la llamada", "Automarcado", " ")
           If tmpObs <> "" Then
               txtObservacionesLlamada = "" & UCase(tmpObs)
           End If
       End If
       
       InBuff = ""
       Call ActualizaEstatusLlamada(NO_CONTESTO)
       txtObservacionesLlamada = ""
       Call ColgarTelefono
       Call Actualiza
       ' Se mueve al siguiente registro
       If TDBG1.EOF Then
           TDBG1.MoveFirst
       Else
           TDBG1.MoveNext
       End If
       
       Exit Sub
       
    End If
     
    If InStr(InBuff, "ERROR") Then
       InBuff = ""
       MsgBox "Ocurrio un error al marcar al número " & TDBG1.Columns("TelCasa"), vbCritical
       Exit Sub
    End If
     

  • 6 years ago

    I'm programming one monitor, sniffer, in VB for RS 232- that works nice when its set to ModeText,
    but when I tryed for comInputModeBinary, the serial port assumes is a array,


    Could you kindly help me?


    Thanks
    ->The Code:


    Private Sub Command1_Click()
    Dim buffer0, buffer As String
    Dim dados As String
    Dim TheMsg() As Byte, sTemp$


    Text1.Text = ""
    If Not (MSComm1.PortOpen) Then
      MSComm1.PortOpen = True
      End If
       MSComm1.InputMode = 1 ' Set InputMode to read binary data
            ' If MSComm1.InBufferCount > 0 Then
            ' buffer0 = MSComm1.Input
               While w <= 204809
                  DoEvents
                  w = w + 1
                  sTemp = MSComm1.Input
                  TheMsg = sTemp
                   If UBound(TheMsg, 1) > -1 Then
                       'Dim p&, i&
                       'p& = LBound(TheMsg)
                       Text1 = Text1 & UBound(TheMsg, 1)
                   End If
                  'Text1 = StrConv(MSComm1.Input, vbFromUnicode)
                  'dados = (Mid(MSComm1.Input, w, 1))    
                  'If dados <> "" Or dados <> Null Then
                   'buffer = Asc(Mid(MSComm1.Input, w, 1)) 'convert each binay value to ASCII
                  'buffer0 = Hex(Mid(buffer, w, 1))   'convert each binay value to ASCII
                  'Text1.Text = Text1.Text + buffer + Chr$(32)
                  'End If
                Wend
              '  Text1.Text = Text1 + buffer
            '  End If
         w = 0
    End Sub


  • 6 years ago

    Hi
    I'm programming one monitor, sniffer, in VB for RS 232- that works nice when its set to ModeText,
    but when I tryed for comInputModeBinary, the serial port assumes is a array,


    Could you kindly help me?


    Have a look at the code.


    Private Sub Command1_Click()
    Dim buffer0, buffer As String
    Dim dados As String
    Dim TheMsg() As Byte, sTemp$


    Text1.Text = ""
    If Not (MSComm1.PortOpen) Then
      MSComm1.PortOpen = True
      End If
       MSComm1.InputMode = 1 ' Set InputMode to read binary data
            ' If MSComm1.InBufferCount > 0 Then
            ' buffer0 = MSComm1.Input
               While w <= 204809
                  DoEvents
                  w = w + 1
                  sTemp = MSComm1.Input
                  TheMsg = sTemp
                   If UBound(TheMsg, 1) > -1 Then
                       'Dim p&, i&
                       'p& = LBound(TheMsg)
                       Text1 = Text1 & UBound(TheMsg, 1)
                   End If
                  'Text1 = StrConv(MSComm1.Input, vbFromUnicode)
                  'dados = (Mid(MSComm1.Input, w, 1))     'convert each binay value to ASCII
                  'If dados <> "" Or dados <> Null Then
                   'buffer = Asc(Mid(MSComm1.Input, w, 1)) 'convert each binay value to ASCII
                  'buffer0 = Hex(Mid(buffer, w, 1))   'convert each binay value to ASCII
                  'Text1.Text = Text1.Text + buffer + Chr$(32)
                  'End If
                Wend
              '  Text1.Text = Text1 + buffer
            '  End If
         w = 0
    End Sub

  • 6 years ago

    Dim Communications As MSCommLib.MSComm
    Set Communications = CreateObject("MSCommLib.MSComm")


    This is if you want to instantiate the MSComm control as an object, so go to Project menu in your VB IDE and down to references and make sure you add the MSCommLib reference.


    If you just want to use it as a control, then dont need to instantiate it as an object.


    sal

  • 6 years ago

    I already completed a program to communicate with 8052(microcontroller).  when i sent a byte to get 8052 attention it seems that the i havent received any acknowledgement from 8052.  Until now i cannot figured out how to solve this problem.  Is there anything wrong with the mscomm that the 8052 is not responding or it is the hardware problem?

  • 6 years ago

    I already completed a program to communicate with 8052(microcontroller).  when i sent a byte to get 8052 attention it seems that  i havent received any acknowledgement from 8052.  Until now i cannot figured out how to solve this problem.  Is there anything wrong with the mscomm that the 8052 is not responding or it is the hardware problem?

  • 6 years ago

    I have a issue with MSComm, I will be receiving messages without any problems and all of a sudden, information will stop just coming in.  Do you know any reason for this.

  • 5 years ago

    I have connected my phone to modem and modem to my computer. what i need is, when somebody pick-up his phone as dial by me, i should be notified. I know how to dial others phone, but don't know how to receive the voice or data. kindly suggest.

  • 5 years ago

    Hi
    I want a program which can dial the number, if somebody pick-up the number, his phone no as well as name should be entered in my computer database. I have a list of all phone number along with their name. I suceeded in getting the phone number with honour name and also i am able to dial through my computer. The problem is when somebody pick-ups the phone, I am unaware of that and even if somebody press some button say 5, i am not able to trace the tone or data. I am using an external modem and it is configured properly. My source program is:


    Private Sub cmdDial_Click()
     On Error Resume Next
     Dim str As String, dummy
     str = InputBox("Enter the phone no", "Dialer", 27)
     MSComm1.CommPort = 2
     MSComm1.PortOpen = True
     MSComm1.Output = "ATDT" + str + vbCr
     Do
       dummt = DoEvents()
             Text1.Text = Text1 + MSComm1.Input    'StrConv(MSComm1.Input, vbUnicode)
            Text2.Text = Text2 + MSComm1.Output  'StrConv(MSComm1.Output, vbUnicode)
     Loop
    End Sub


    Private Sub Form_Load()
     MSComm1.DTREnable = True
     MSComm1.InBufferSize = 100
     MSComm1.InputLen = 0
     MSComm1.InputMode = comInputModeText
     MSComm1.NullDiscard = True
     MSComm1.OutBufferSize = 100
     MSComm1.RThreshold = 1
     MSComm1.RTSEnable = True
     MSComm1.Settings = "9600,N,8,1"
     MSComm1.SThreshold = 1
     MSComm1.Handshaking = comRTSXOnXOff ' GetSetting(App.Title, "Properties", "Handshaking", "") 'frmTerminal.MSComm1.Handshaking
    End Sub


    Private Sub MSComm1_OnComm()
     On Error Resume Next
     Dim i As Integer, j
     For i = 0 To 1255
       For j = 0 To 1255
       Next
     Next
     
      Select Case MSComm1.CommEvent
         Case comEventBreak   ' A Break was received.
         Case comEventFrame   ' Framing Error
         Case comEventOverrun   ' Data Lost.
         Case comEventRxOver   ' Receive buffer overflow.
         Case comEventRxParity   ' Parity Error.
         Case comEventTxFull   ' Transmit buffer full.
         Case comEventDCB   ' Unexpected error retrieving DCB]
         Case comEvCD   ' Change in the CD line.
           Text1.Text = test1.Text & "1"
         Case comEvCTS   ' Change in the CTS line.
           Text1.Text = Text1.Text & "2"
         Case comEvDSR   ' Change in the DSR line.
           Text1.Text = Text1.Text & "3"
         Case comEvRing
           Text1.Text = Text1.Text & " Ring" & vbCrLf
         Case comEvReceive   ' Received RThreshold # of
           Text1.Text = Text1.Text & StrConv(MSComm1.Input, vbUnicode) & vbCrLf
         Case comEvSend   ' There are SThreshold number of
           Text1.Text = Text1.Text & " 5 " & StrConv(MSComm1.Input, vbUnicode) & vbCrLf               ' characters in the transmit
         Case comEvEOF   ' An EOF charater was found in
           Text1.Text = Text1.Text & "6"              ' the input stream
      End Select
    End Sub


    Please help me how to solve this problem.

  • 5 years ago

    You should try using a laser scanner with rs232 and connecting it to an odbc data base. Thats a trip. Control is rock solid though.

  • 5 years ago


         Hi, Ezmy!


         I have just seen your message, and I have a problem with the communication with MSComm like your problem. I'm doing a communication between PC and one sort of multimeters, and it is possible for me to read the data from them but not to send command in order to control them.


         If you would like, you could send to me your program and your question, and we will investigate what is the trouble.


         Let's meeting by e-mail.


         Chenel.                                       carloslis13@hotmail.com

  • 5 years ago

    hi virdi_ds,


     trapping the callerid through the modem is the project i'm currently doing.
    i got the caller id provision from the telephone company and have checked it.
    but my conexant hcf data fax modem is not helping me in capturing the number.
    may i know which modem ur using?
    have u got idea of how a telephone conversation can be recorded?
    please help
     john

  • 5 years ago

    hi, when I comm with my motor via com1, it show receive break and frame error. why is that? |I have set the "setting" 9600,7,1

  • 5 years ago

    i want to develope a online billing system


    first i have to dial a telephone number by press the number on the telephone
    how the dial number print in vb text box

  • 5 years ago

    mm the explanation is ok.


    but u didn't explain if there is something goes wrong, how we would solve theproblem ?


    i got NO CARRIER response from my Itegno modem ?


    so any idea ?

  • 5 years ago

    i need to know how to trace the numbers being pressed on the phone after a call is connected(MSComm)?.

  • 5 years ago

    I also would be very interested in a solution for a W98 PC.



    My work around is to use the GetAvailablePorts function of the program which gets the COM port. Then just strip out the others

  • 5 years ago

    Quote:
    [1]Posted by kalp on 19 Mar 2003 04:41 AM[/1]
    i want to develope a online billing system


    first i have to dial a telephone number by press the number on the telephone
    how the dial number print in vb text box

  • 5 years ago

    The problem (at least in Win 95) is Security Attributes. Change the Alias at the top of the function so that instead of taking his user defined SECURITY_ATTRIBUTES data structure, it takes a Long. Then, pass a zero (aka NULL) to indicate default security attributes. This seems to fix it.

  • 5 years ago

    Forgot one thing: When passing the zero, use the syntax "ByVal 0&". This seems to pass a null pointer.

  • 5 years ago

    Receiving no data when key is pressed after the phone is connected
    pls help me its very very urgent

  • 5 years ago

    Does anyone know how to access COM ports above 9?
    I am currently using the RS232.vb module in VB.NET.


    Thanks,


    - Steve

  • 5 years ago

    I have had a look at the code and run the program in the screen shot however when you get a response from the modem ie. No Carrier it is spread over two lines ie NO CAR
                                                                             RIER


    Why is this and what is the Fix.......



    Thanks in advance .......Richard

  • 5 years ago

    Hi


    I am Karthik and I am involved in developing a SMS Application using GSM Itegno modem. I am


    facing some problems in reading the SMS message from modem. I am using C# language and


    windows 2000 Professional operating System.


    Problem




    While reading a particular message, I am getting the message received along with the message I have sent previously from the modem. Please help to solve this issue.


    Thanks you in advance



    Regards
    C.S.Karthikeyan

  • 5 years ago

    how to receive the telephone call through modem using Vb. actually it does not established the connection with telephone

  • 5 years ago

    Hey,


    Is this Karthik Nahender?


    If so, send me email at dia.abavar@terra.com.br


    If not, oh well.......




  • 5 years ago

    Karthik,


    check if


    AT+CMGF?
    iF RETURN IS ZERO, PLEASE set at+cmgf=1 and at&w to save

  • 5 years ago

    check if


    AT+CMGF?
    iF RETURN IS ZERO, PLEASE set at+cmgf=1 and at&w to save

  • 5 years ago

    hi
    already i am using AT+CMGF=1 ( i.e in Text mode option ).
    i am able to send and receive using the itegno modem. i only issue is that while receiving the message , i am getting the received message plus the previously sent message.


    this happens only when too many messages are sent and received continuously.
    please help me to solve this problem.
    Thanking you
    Karthik

  • 5 years ago

    "hi
    already i am using AT+CMGF=1 ( i.e in Text mode option ).
    i am able to send and receive using the itegno modem. i only issue is that while receiving the message , i am getting the received message plus the previously sent message.


    this happens only when too many messages are sent and received continuously.
    please help me to solve this problem.
    Thanking you
    Karthik"


    Are you sending message to your own number? That's why you see all the messages ? Did you clear the buffer ?
    Please write e-mail directly to developers@itegno.com for more help

  • 5 years ago

    hi thanks for your reply


    please help me how to clear the buffer in the modem.
    i am using AT+CMGR -> for receiving and At+CMGS -> for sending and AT+CMGD-> for deleting the message in the modem.


    is there any command available to clear the buffer?


    Thanks
    Regards
    Karthik

  • 5 years ago

    For whatever reason none of my comm ports are registering as available on either one of my computers (both w98se).  When I try to run the program (the one with the screen shot on pg3)
    I get:
    Run-time error '380'
    Invalid Property value


    as far as I can tell this happens at the end of ListComPorts()
    ...
    cboComm.ListIndex = 0 <----- Since nothing ever populated the cboBox, index is -1 and the assignment fails.


    Has anybody else run into this problem?...I've tried adding ports through windows add hardware but no luck.  Thanks for any help you can provide


    --jeremy

  • 4 years ago

    Can someone please tell me how to give the output command to a modem in C#.  I have tried everything and I think the problem is trying to duplicated VB.NET's vbCR constant in C#.  Here is the command I am trying:


               string Buffer = "ATDT 916016644844 \n";
               Object oBuffer = (object)Buffer;
               axNETComm1.PortOpen = true;
               axNETComm1.set_Output(ref oBuffer);


    Can anyone please give me some suggestions?????


    Thanks,
    Kendal

  • 4 years ago

    Great tutorial - got some serial weighing-scales implemented into our system in under an hour.

  • 4 years ago

    Thanks for this great tutorial.
    I would like to know How to use the MSComm control inside a Activex DLL, in other words, How can I use the control without obtain and Object Variable Definition error from the server application.


    Regards,
    Marcelo.

  • 4 years ago

    I used the "list available com ports" function and it worked great until I used a PCMCIA socket card that assigned the com port number 10 to the serial port. I couldnt get it to list. I went into device manager and changed it back to number 7 and it showed up fine.


    Any suggestions?


    Thanks
    Pranav

  • 4 years ago

    I am facing the same problem also! And the curious thing is that after unsuccesfully reading from the modem... all the data is thrown out when i connect with hyperterminal.

  • 4 years ago

    Its me again. Found the solution of my problem.


    Add one more \ in front of ".\COM"  in line hCOM = CreateFile("\.\COM" ....


    i.e. Originally the line was
    hCOM = CreateFile(".\COM" ....


    make it
    hCOM = CreateFile("\.\COM" ....


    to work for comports above 9.

  • 4 years ago

    The com ports are not listed thru VB but are available in the device manager of My Computer.  How to go about?

  • 4 years ago

    Pls help me how to recoeve message.Give the sample code.

  • 4 years ago

    Quote:
    [1]Posted by virdi_ds on 29 Jan 2003 08:33 AM[/1]
    Hi
    I want a program which can dial the number, if somebody pick-up the number, his phone no as well as name should be entered in my computer database. I have a list of all phone number along with their name. I suceeded in getting the phone number with honour name and also i am able to dial through my computer. The problem is when somebody pick-ups the phone, I am unaware of that and even if somebody press some button say 5, i am not able to trace the tone or data. I am using an external modem and it is configured properly. My source program is:


    Private Sub cmdDial_Click()
     On Error Resume Next
     Dim str As String, dummy
     str = InputBox("Enter the phone no", "Dialer", 27)
     MSComm1.CommPort = 2
     MSComm1.PortOpen = True
     MSComm1.Output = "ATDT" + str + vbCr
     Do
       dummt = DoEvents()
             Text1.Text = Text1 + MSComm1.Input    'StrConv(MSComm1.Input, vbUnicode)
            Text2.Text = Text2 + MSComm1.Output  'StrConv(MSComm1.Output, vbUnicode)
     Loop
    End Sub


    Private Sub Form_Load()
     MSComm1.DTREnable = True
     MSComm1.InBufferSize = 100
     MSComm1.InputLen = 0
     MSComm1.InputMode = comInputModeText
     MSComm1.NullDiscard = True
     MSComm1.OutBufferSize = 100
     MSComm1.RThreshold = 1
     MSComm1.RTSEnable = True
     MSComm1.Settings = "9600,N,8,1"
     MSComm1.SThreshold = 1
     MSComm1.Handshaking = comRTSXOnXOff ' GetSetting(App.Title, "Properties", "Handshaking", "") 'frmTerminal.MSComm1.Handshaking
    End Sub


    Private Sub MSComm1_OnComm()
     On Error Resume Next
     Dim i As Integer, j
     For i = 0 To 1255
       For j = 0 To 1255
       Next
     Next
     
      Select Case MSComm1.CommEvent
         Case comEventBreak   ' A Break was received.
         Case comEventFrame   ' Framing Error
         Case comEventOverrun   ' Data Lost.
         Case comEventRxOver   ' Receive buffer overflow.
         Case comEventRxParity   ' Parity Error.
         Case comEventTxFull   ' Transmit buffer full.
         Case comEventDCB   ' Unexpected error retrieving DCB]
         Case comEvCD   ' Change in the CD line.
           Text1.Text = test1.Text & "1"
         Case comEvCTS   ' Change in the CTS line.
           Text1.Text = Text1.Text & "2"
         Case comEvDSR   ' Change in the DSR line.
           Text1.Text = Text1.Text & "3"
         Case comEvRing
           Text1.Text = Text1.Text & " Ring" & vbCrLf
         Case comEvReceive   ' Received RThreshold # of
           Text1.Text = Text1.Text & StrConv(MSComm1.Input, vbUnicode) & vbCrLf
         Case comEvSend   ' There are SThreshold number of
           Text1.Text = Text1.Text & " 5 " & StrConv(MSComm1.Input, vbUnicode) & vbCrLf               ' characters in the transmit
         Case comEvEOF   ' An EOF charater was found in
           Text1.Text = Text1.Text & "6"              ' the input stream
      End Select
    End Sub


    Please help me how to solve this problem.

  • 4 years ago

    hi
    can you help me for get caller id from modem.
    i use vc++ compiler and work with com port by
    CreatFile function.
    and use at command
    i used following command but it not worked correctly
    and i cant get caller id.


    at+fclass=8
    at+vcid=1


    thanks


  • 4 years ago

    Please help me to get the SMS message to be stored in Database

  • 4 years ago

    Hi All,
    I have just started using MSComm for serial comunication.
    I have heard that we need to close port after we send data once..... and we again need to open port if we want to send data again.
    Actually I am using this for communication with a device.
    For the first message that I send, I do get an acknowledge.... but when I send the second message(command) I don't get an acknowledge.
    Also how do we know whether data has actually been written on the port or not?
    Can someone please help me on this.


    Thanks all.

  • 4 years ago

    A friend of mine gave me his machine to fix after he butchered it. He's run a 98 setup CD again and it gets as far as requesting the product registration. I don't want to enter a product key, but revert the machine back to it's original state. What files do I need to edit or remove to stop the machine booting into the setup screen every time and boot normally as it did before?


    A simple solution would be to enter the product key and let it run but I don't want to bugger up all the applications that are currently installed and start re-installing all the stuff all over again. Any help would be appreciated :-)

  • 4 years ago

    Hello, I need some hlep here, Dose MSCommm work with USB? I have Itegno300 with USB , can I deal with it via MSCOMM?
    thank you for your prompt response!

  • 4 years ago

    Thanks for prjMSComm, very useful. However I found and fixed a problem with the COMAvailable Function.
    The problem appears to be that Createfile has a problem with the concatenation of ("COM" & COMNum  & ""...etc) in the original function
    I ran into this problem using an add-in 8 port com card and could not find COM 10 with the code snippet that I put into my project. Even though the project
    actually requires only up to COM 9, I would not rest until I solved this. I did not find any relevant documentation about this condition researching the Createfile API function and ended up finding the solution on a Delphi posting!  Serial I/O (RS232) Using Delphi (RS232)



    Serial I/O (RS232) Using Delphi (RS232)


    I have modified your "COMAvailable" function to use a helper function called "GetAlias" which simply parses the proper string to feed to the
    "CreateFile" function.


    I hope this is helpful... c.caduff@racalate.com








    '// This detects if a COM ports is available.
    '// Used by the ListComPorts() procedure
    '// Returns TRUE if the COM exists, FALSE if the COM does not exist
    Public Function COMAvailable(COMNum As Integer) As Boolean
       Dim hCOM As Long
       Dim ret As Long
       Dim sec As SECURITYATTRIBUTES
       'New variable to hold results of GetAlias
       Dim commHandle As String
       
       'Original
       'try to open the COM port
    '    hCOM = CreateFile("COM" & COMNum & "", 0, FILE
    SHAREREAD + FILESHAREWRITE, sec, OPENEXISTING, FILEATTRIBUTENORMAL, 0)
       
       'Modified
       'get alias which works on all Com ports
       commHandle = GetAlias(COMNum)
       'revised call uses commHandle returned from "GetAlias" function
       hCOM = CreateFile(commHandle & "", 0, FILESHAREREAD + FILESHAREWRITE, sec, OPENEXISTING, FILEATTRIBUTE_NORMAL, 0)
       If hCOM = -1 Then
           COMAvailable = False
       Else
           COMAvailable = True
           'close the COM port
           ret = CloseHandle(hCOM)
       End If
    End Function
    'Patch function to allow CreateFile to get handle for Com Port higher than Com 9
    Public Function GetAlias(nIndex As Integer) As String


    Dim port As Integer
    Dim result As String
       
       port = nIndex
       
       Select Case port
               Case 1:   result = "\.\COM1"     'Port 1
               Case 2:   result = "\.\COM2"     'Port 2
               Case 3:   result = "\.\COM3"     'Port 3
               Case 4:   result = "\.\COM4"     'Port 4
               Case 5:   result = "\.\COM5"     'Port 5
               Case 6:   result = "\.\COM6"     'Port 6
               Case 7:   result = "\.\COM7"     'Port 7
               Case 8:   result = "\.\COM8"     'Port 8
               Case 9:   result = "\.\COM9"     'Port 9
               Case 10:  result = "\.\COM10"    'Port 10
               Case 11:  result = "\.\COM11"    'Port 11
               Case 12:  result = "\.\COM12"    'Port 12
               Case 13:  result = "\.\COM13"    'Port 13
               Case 14:  result = "\.\COM14"    'Port 14
               Case 15:  result = "\.\COM15"    'Port 15
               Case 16:  result = "\.\COM16"    'Port 16
               
               
       End Select
       
       GetAlias = result


    End Function

  • 4 years ago

    James-


    Perhaps you should mention that your code as posted, for checking the COM ports, doesn't work under Windows 98, ME, or CE.


    In order for it to work under thoses OSes, you must make the following changes:


    1) Change the 4th parameter in the declaration of CreateFile() from [courier new]lpSecurityAttributes As SECURITY_ATTRIBUTES[/courier new]  to [courier new]lpSecurityAttributes As Any[/courier new]


    2) When you call the CreateFile() function, change its 4th parameter to [courier new]ByVal CLng(0)[/courier new] . Just passing plain old 0 (zero) won't work.



    The code as posted works under NT, 2000, and I would think later versions (XP), but I haven't tested it.



    Cheers,



    -Andrew

  • 4 years ago

    To send and receive SMS, Dinkum Technology Pte Ltd (Singapore) provides API. The features includes Send and Receive SMS, Maintain Phone Books, Voice Call, Data Call, Alarm and lot more.


    http://www.dinkum.com.sg/products/hardware-wmapi.asp


    WM-API is easy to use. It needs only 3 lines of code to send SMS from a Visual Basic application. It also supports Java, Visual C++, Delphi and .NET.


    Dinkum is also distributors for Wavecom modems. You can purchase Wavecom Fastrack Modems, Quik Modem Modules, Integra Modem Modules from Dinkum Technology Pte Ltd. Please visit www.dinkum.com.sg for more details.


    You can also send your questions on sending receiveing SMS and questions related to GSM modems to technical@dinkum.com.sg

  • 4 years ago

    I think u need to clear the buffer, before your commport load the second data in . it will be a very hard time when you first time do the commport connection. try your best

  • 4 years ago

    if u got the answer please send to me also vpbashir@eim.ae

  • 4 years ago

    Instead of Clng(0), you can use 0&.

  • 4 years ago

    change
    hCOM = CreateFile(".\COM" & COMNum & "", 0, FILESHAREREAD + FILESHAREWRITE, sec, OPENEXISTING, FILEATTRIBUTENORMAL, 0)
    to
    hCOM = CreateFile("\.\COM" & COMNum & "", 0, FILE
    SHAREREAD + FILESHAREWRITE, sec, OPENEXISTING, FILEATTRIBUTENORMAL, 0)


  • 4 years ago

    How can i move a print job from one queue to another queue using windows API functions,structures and contants.I can receive the job info but not the job's data(Contents) itself.

  • 4 years ago

    How can I send  a print job, directed to LPT1 , to a Network port programatically without pinning the network path to LPT1 at the command promt.(Win2k/XP)

  • 3 years ago

    Hi


    I have been trying to work with MSComm control. I am able to recieve messages but not send any. I am working on transmitting messages to a video modulator. The code works in VC++ though it is a different library. It does not work out in VB 6.0. The problem is not with the hardware. I got  comEventFrame and comEventRxOver errors. My settings are proper. Can you help with the same?


    Regards,
    SR

  • 3 years ago

    I am trying to send the "Page Down" key to the output buffer. Any ideas on how?


    Thanks,


    g

  • 3 years ago

    I have heard that MSCOMM can only handle upto 16 ports only.
    Is this really true?