mscomms empty string?

  • 10 years ago
       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?


    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 = ""
    txtCell(i + 1).Text = DataArray(i)
    End If
    txtCell(i + 1).Locked = False
    Next i
        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).


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.

“If debugging is the process of removing software bugs, then programming must be the process of putting them in.” - Edsger Dijkstra