Click here to Skip to main content
16,019,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
we are having an external device in which already the code was loaded in hex format and through vb6 via rs232 i have to download the data as a new file in my laptop help me how to do this

eg: the hex code present in the external device was
:108000000000000300000000000603000304030456

i have to download this format using vb6 coding to my laptop

thank you

What I have tried:

VB
Option Explicit
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset

Private Sub configure_Click()

    Form2.Show

End Sub

'Sub rs232()
    'Dim temp_varc, serialen, keyvolume
    'if (temp_varc=0x38) then
        'serialen = 1
        'upload
        'serialen = 0
        'keyvolume (5000)
    'End If
'End Sub
Private Sub upload_Click()

    Dim ff, i As Integer
    Dim temp_varc, serialen, keyvolume
    Dim address, buf, strtbyte As String
    'buf = Space(50)

     If MSComm1.PortOpen = True Then
        With CommonDialog1
        .InitDir = App.Path
        .FileName = ""
        .Filter = "Hex File (*.hex)|*.hex"
        .ShowSave

        ff = FreeFile
        Open .FileName For Output Lock Read As #ff
            'Form1.Label3.Caption = "Entering While Loop and Waiting For Command"

            address = 8000
            Print #ff, ("1 ")
            'gets(buf, Space(50))

            While (address < 8090)
                Print #ff, ("2 :10" & address & "00")
                'sendblock (address)
                address = address + Hex$(16)
            Wend
            
            address = 8000
            While (address < 8090)
                Print #ff, ("3 :10" & address & "00")
                'sendblock (address)
                address = address + Hex$(16)
            Wend
            
            Print #ff, ("3 :00000001FF")
            Print #ff, ("4 ")
 
        Close #ff
        
    End With
    End If
 
End Sub
Posted
Updated 20-Mar-18 23:28pm
v2
Comments
CHill60 21-Mar-18 4:44am    
What is wrong with the code you already have?
Member 13396059 21-Mar-18 5:13am    
it is not downloading the data from the device

1 solution

Your code snippet does not include any reading from the serial port.

I suggest to read about MSComm Control (MSComm Control)[^]. A simple example can be found at MSComm Control Example (MSComm Control)[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900