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

Thanks for your help.

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

dim Dani as new Form2

Thanks a lot.
It resolved my problem.

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

VB Code.


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)
            Dim operationCount As Integer = insertCommand.ExecuteNonQuery
        Catch ex As SqlClient.SqlException
        End Try

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.

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...

This article has been dead for over six months. Start a new discussion instead.