Question

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
Was it helpful?

Solution 3

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

OTHER TIPS

Did you see the Arrays of views tutorial?

Your code is wrong. You are declaring button1 and button2 which are never initialized or assigned. The simplest solution is to use the Tag property to mark each button and then check clickButton.Tag and find which button was pressed.

Avoid the confusion - simply use the Designer to add the views and then use "Tools .... Generate Members" to add all your Dim statements and Event statments.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top