Hi and Hello

I just wonder where to put the click event of a commandbutton
in this code, the command button is for the alphebet and are
indexed from 0 to 28

Dim startpos, extpos
Dim Entry As ADRDATA, NumRecs, i
Dim tmpStr As String
Dim strDatum As String

'Dim x
'For x = 0 To 28 '*********************** Equal to the alphabet
' SSCommand2(x).ForeColor = vbblue
' Next
   
    FileNum = FreeFile
    Open DATAFILE For Random As #FileNum Len = Len(Entry)
    CommFileNum = FreeFile
    Open COMMENTSFILE For Binary As #CommFileNum
    NumRecs = LOF(FileNum) / Len(Entry)
    
    For i = 1 To NumRecs
        Get #FileNum, i, Entry
        
        If Not Entry.Deleted Then
            
            tmpStr = Trim$(Entry.EfterNamn) & ", " & Trim$(Entry.FörNamn)
            '****** efternamn = surename                Förnamn = forname
            AdressLista.AddItem tmpStr
            '****** adresslista = adresslist
            AdressLista.ItemData(AdressLista.NewIndex) = i
        End If
       
    TotProdId = TotProdId + 1
   
    If AdressLista.ListCount > 0 Then AdressLista.ListIndex = 0
   
Next

Edited 4 Years Ago by WaltP: Your posts are unreadable because you refuse to use CODE Tags..

so what do you want to achieve, when they click a letter it returns the names from the file that start with that letter?

Yes and then it should list it in a listbox(adresslista)
the surename and the forename

the string is
1: tmpStr = Trim$(Entry.EfterNamn) & ", " & Trim$(Entry.FörNamn)
2: '****** efternamn = surename Förnamn = forname

the tmpstr get the shall get the appriated name corresponding to the command.click

create an array of buttons that all respond to the same click event.

Assuming each button has a single letter on it, eg A, change line 20 to be

If Not Entry.Deleted And Command1.item(Index).caption = left$(Entry.FörNamn)   Then

Edited 4 Years Ago by ChrisPadgham: n/a

oops left the number of characters of the left function try this

If Not Entry.Deleted And Command1.item(Index).caption = left$(Entry.FörNamn,1)

so what is the problem, have you set a break point in the code and stepped through to see whether it is entering the code and if so what it is doing

This article has been dead for over six months. Start a new discussion instead.