0

I am using VB.NET using Visual Stduio 2005. From a Windows application, how to execute another form?

Thanks for your help.

6
Contributors
10
Replies
14
Views
9 Years
Discussion Span
Last Post by tomato.pgn
0

you need to declare form name as object and use it to call that form.
ex :

dim Dani as new Form2
Dani.show
0

Thanks a lot.
It resolved my problem.

But if you want to load a form you would use something like this:

VB Code.

FormName.Show()

0

Here's the code I tried to use, but obviously you can't update two table in one insert statement because my code doesn't work:

Private Sub btnSaveToDB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveToDB.Click

        Dim connection As SqlClient.SqlConnection = getConnection()
        Dim insertStatement As String _
            = "INSERT Operations, Operation_Dates" _
            & "(Operation, Date) " _
            & "VALUES (@Operation , @Date )"
        Dim insertCommand As New SqlClient.SqlCommand(insertStatement, connection)
        insertCommand.Parameters.AddWithValue("@Operation", txtOperation.Text.Trim)
        insertCommand.Parameters.AddWithValue("@Date", txtDate.Text.Trim)
        Try
            connection.Open()
            Dim operationCount As Integer = insertCommand.ExecuteNonQuery
        Catch ex As SqlClient.SqlException
            MessageBox.Show(ex.Message)
        Finally
            connection.Close()
        End Try
0

You can select which form loads first by just changing your project's startup form. Just right click on the Project, click Properties, Application tab, change the "Startup form" setting.

0

See the concept behind this is that you can do this by first writing form name ,then the control field that you want to use and the action u want to perform...
eg:-

form1.textbox1.text="abc"
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.