954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Command Button

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
bonzo2008
Light Poster
Team Colleague
27 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
 

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

ChrisPadgham
Posting Pro in Training
413 posts since Sep 2009
Reputation Points: 102
Solved Threads: 78
 

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

bonzo2008
Light Poster
Team Colleague
27 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
 

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
ChrisPadgham
Posting Pro in Training
413 posts since Sep 2009
Reputation Points: 102
Solved Threads: 78
 

hello again I tried it but don't still work as weill

bonzo2008
Light Poster
Team Colleague
27 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
 

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)
ChrisPadgham
Posting Pro in Training
413 posts since Sep 2009
Reputation Points: 102
Solved Threads: 78
 

Hello
I have tried that to but still don'i work

bonzo2008
Light Poster
Team Colleague
27 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
 

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

ChrisPadgham
Posting Pro in Training
413 posts since Sep 2009
Reputation Points: 102
Solved Threads: 78
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You