mscomms empty string?

  • 10 years ago
    Hi,
       I'm a newbie to vb and am trying to recieve 256 byte's from a comms port but i don't get any data displayed.
    i have tried this code with a comms ocx called "epeserial" and it works ok, but not with mscomm.
    What am i doing wrong?

          thanks
                 scott

    Private Sub dwn_ld_Click()
    With MSComm1
    Dim bError                          As Boolean
    Dim com_data   As String
        
        dwn_ld.Enabled = False ' We don't want users to keep pressing this
        Screen.MousePointer = vbHourglass ' Signal were busy - this is going to take some time
        
        If .PortOpen = True Then .PortOpen = False

    .CommPort = 1
    .Settings = "9600,N,8,1"
    .DTREnable = False
    .RTSEnable = False
    .RThreshold = 0
    .SThreshold = 0

    .InputMode = 0 'cimInputModeText
    .PortOpen = True
     .Output = "D" ' tell system to send 256 bytes
                   
    com_data = com_data & MSComm1.Input


    com_data = StrConv(com_data, vbFromUnicode)

    Dim DataArray() As String
    Dim i As Long
    VScroll.Value = 0
    VScroll.Max = GetFileLength(CD.FileName) \ 256
    lblStatus.Caption = "Status: Opening File"
    DataArray = Split(ASCII(com_data), " ")
    Loading = True
    For i = 0 To 255
    If i > UBound(DataArray) Then
    txtCell(i + 1).Text = ""
    Else
    txtCell(i + 1).Text = DataArray(i)
    End If
    txtCell(i + 1).Locked = False
    Next i
    txtCell(1).SetFocus
        Screen.MousePointer = vbDefault
        
        dwn_ld.Enabled = True ' Ready to run again
       End With
       
       End Sub






















































Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Nine people can't make a baby in a month.” - Fred Brooks