Results 1 to 15 of 15

Thread: ListBox - finding specific data and index

Threaded View

  1. #1

    Thread Starter
    Junior Member JeezyWonder's Avatar
    Join Date
    Jul 2017
    Posts
    28

    ListBox - finding specific data and index

    Hello everyone, what i'm doing now, it's read info from CANBUS and put it in the listbox in vb6. It looks like
    Code:
     tmp = idtag.Text & vbTab & dlc.Text & vbTab & RxData.Text
    SO what i have in listbox after a get it its Name:  cunbuserr123.jpg
Views: 2316
Size:  16.6 KB
    so as you can see i have two id 140, so it means listbox just add new line every time. What i want it's make it read ID then if its equal to id that we receive from CANBUS, we put data exactly to that ID. Like "if ID from CANBUS = ID in LISTBOX then update data from CANBUS in that ID, if received id doesnt excist in listbox, then add new item". As you can see from a picture i recevie data from canbus in one like, ID+DLC+DATA like this "0000014008BBBBBBBBBBBBBBBB" then i extract right values from with MID() then add to listbox. My code is:
    Code:
    Select Case MSComm1.CommEvent
        Case comEvReceive
        Buffer = MSComm1.Input
        Text1.Text = Text1.Text & Buffer
        If Len(Text1.Text) = 26 Then
        Text4 = Text1
            idtag.Text = Mid(Text1.Text, 6, 3)
            dlc.Text = Mid(Text1.Text, 10, 1)
            RxData.Text = Mid(Text1.Text, 11, 16)
            'Call Command1_Click
            RxData.Text = Right(Text1.Text, Val(dlc.Text * 2))
            RxData = SpaceIt(RxData)
            tmp = idtag.Text & vbTab & dlc.Text & vbTab & RxData.Text
            If List1.ListCount > 14 Then List1.RemoveItem (a)
            List1.AddItem tmp, a
            Text1.Text = ""
            a = a + 1
            If a > 14 Then
                'List1.Clear
                a = 0
            End If
        End If
    End Select
    End Sub
    Any ideas? aprecciate any input. Thanks
    Attached Images Attached Images   
    Last edited by JeezyWonder; Aug 16th, 2017 at 12:23 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width