在VB.NET中打开新表单

时间:2016-02-05 12:15:10

标签: vb.net forms

在我的一个表单类中,在按钮单击事件中,我需要打开一个新表单。这是我的代码;

Private Sub btnEditReservation_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEditReservation.Click


    Dim ResultResSearch As New SearchResultDiag
    Dim DbAccess As New SQL
    Dim SQLString As String
    Dim Result(,) As String
    Dim sDate, sTime As String

    Select Case CaseIDTY
        Case 1
            SQLString = "SELECT Reservation.DateTime, Reservation.GuestName, [Table+Reservation].TableID FROM Reservation INNER JOIN [Table+Reservation] ON Reservation.ReservationID=[Table+Reservation].ReservationID WHERE Reservation.DateTime LIKE '" & DTPickerEDT.Text & "%'"
            Result = DbAccess.Read_Array_DB(SQLString)
            If Result.Length = 0 Then
                ErrorNotFound()
                Exit Sub
            End If
            For i = 0 To (Result.Length / 3) - 1
                sDate = Mid(Result(i, 0), 1, 10)
                sTime = Mid(Result(i, 0), 10, 5)
                ResultResSearch.ReservationResult.Rows.Add(sDate, sTime, Result(i, 1), Result(i, 2))
            Next

        Case 2

        Case 3

        Case 4

    End Select

    ResultResSearch.ReservationResult.Visible = True
    ResultResSearch.Show()

End Sub

我声明我要打开的表单'Dim ResultResSearch as new SearchResultDiag',并使用'.show()'函数。

调试时,单击事件句柄,没有任何反应。我逐行浏览代码,除了'ResultResSearch.Show()'

外,一切似乎都有效

我已尝试将关机模式更改为关闭最后一个表单的时间。

任何帮助将不胜感激! :)谢谢!

1 个答案:

答案 0 :(得分:-1)

你只需要做SearchResultDiag.show()& me.hide()(隐藏当前表单)。不确定您创建的内容是否有效..您不必声明要打开的表单