locked
VB6 - Can't convert Received data to Hex RRS feed

  • Question

  • I'm using  Visual Basic 6.0

    I can output hex data ok to my device via the serial port and it responds by sending a hex packet back. I can see the hex

    being received by my computer via a comport monitor program.

    When I try to convert this data to hex I get a type 'mismatch error'

     


    Private Sub Form_Load()

    MSComm1.InputLen = 1
    MSComm1.PortOpen = True

    End Sub

     


    Private Sub Command1_Click()

    Dim StrOut As Variant

    'sends StrOut to DUT
    '**********************************
    StrOut = Chr(&H24) & Chr(&HDB) & Chr(&H0) & Chr(&H0) _
             & Chr(&H1) & Chr(&H4) & Chr(&HF7) & Chr(&H75)

     


    MSComm1.Output = StrOut

    b1 = MSComm1.Input
    b2 = MSComm1.Input
    b3 = MSComm1.Input
    b4 = MSComm1.Input
    b5 = MSComm1.Input
    b6 = MSComm1.Input
    b7 = MSComm1.Input
    b8 = MSComm1.Input
    b9 = MSComm1.Input
    b10 = MSComm1.Input
    b11 = MSComm1.Input
    b12 = MSComm1.Input
    b13 = MSComm1.Input
    b14 = MSComm1.Input
    b15 = MSComm1.Input
    b16 = MSComm1.Input
    b17 = MSComm1.Input
    b18 = MSComm1.Input
    b19 = MSComm1.Input
    b20 = MSComm1.Input
    b21 = MSComm1.Input
    b22 = MSComm1.Input
    b23 = MSComm1.Input
    b24 = MSComm1.Input
    b25 = MSComm1.Input
    b26 = MSComm1.Input


    Text1.Text = Hex(b1)

    End Sub


    Private Sub Command2_Click()

    Text1.Text = ""

    End Sub

    Private Sub Form_Unload(Cancel As Integer)

    MSComm1.PortOpen = False

    End Sub

     

    Wednesday, September 6, 2006 7:57 PM

Answers

All replies