Search code examples
basic4android

Choosing a button from a view


I'm stuck with some syntax on figuring out which of 2 buttons in a view was clicked. I have multiple views - so what happens first is text is assigned to the 2 buttons based on the current view - then what I want to have happen is an action based on which button was clicked. My views work ok - it's the button code that I'm trying to figure out. I'm also trying to avoid writing a sub for each individual button click - and want generic code that I can reuse for any of the views that will always have 2 buttons.

Sub catchtheClick
    Dim button1,button2,clickButton As Button
    clickButton = Sender
    If (we figure out which view - view1 for example) Then
        button1.Text = "view1-button1"
        button2.Text = "view1.button2"
        button1.Tag = "btn1"
        button2.Tag = "btn2"
        Select clickButton.Tag
            Case "btn1"
                (we go to another view etc.)
            Case "btn2" Then
                (we go to some other view etc.)
            End Select
    End If
End Sub

Solution

  • I made a few changes - including the location of the button init and event names - all works fine now.