如何将按钮点击传递给其他子例程?

时间:2018-09-17 21:34:24

标签: vb.net button event-handling

我在编码方面是新手。我可以围绕一个工作程序工作,但这是我第一次从头开始创建。这是我的代码,是的,我知道现在可能很混乱。

在逻辑上,我尝试做的事情听起来很简单。

理论: 该应用程序有多个按钮,单击时每个按钮都会提出一个问题。一旦回答,标签将更改以询问另一个问题。如此等等,直到我用完为止。这旨在成为用户的简单应用程序,以逐步对某些测试设备进行故障排除。

我似乎无法弄清楚为什么我不能只说buttonYes = true,然后等等。我觉得它看起来并不复杂。我在论坛附近进行搜索,但似乎找不到类似的内容。

App

Public Class Form1



Class EventHandler


    Public Event buttonYes(ByVal Status As String)

    Private Sub buttonYes_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonYes.Click
        RaiseEvent buttonYes("True")

    End Sub




End Class

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


    buttonYes.Hide()
    buttonNo.Hide()
    title.Hide()
    question.Hide()
    action.Hide()

    title.Text = ""
    question.Text = ""
    action.Text = ""

End Sub



Private Sub buttonNo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonNo.Click

    Dim ans As String
    ans = "False"

End Sub

Private Sub CompButton(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles compFail.Click

    buttonYes.Show()
    buttonNo.Show()
    title.Show()
    question.Show()
    action.Show()

    title.Text = "Component / SAT"
    question.Text = "Are all cables seated properly"

End Sub

Private Sub ComponentFail(ByVal ans)
    'Dim ans As String
    ans = ""

    If ans = "False" Then
        action.Text = "Check cable connections and retest"
    End If
End Sub

Private Sub buttonYes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

结束班级

0 个答案:

没有答案