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

Thanks for your help.

Recommended Answers

All 10 Replies

When you say execute, do you mean call a form?

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

VB Code.

FormName.Show()

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

dim Dani as new Form2
Dani.show

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()

it seems you worked on vb6...if in vb.net you must declare object instead a form.
Happy coding friend :)

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

please ignore my last post, that was supposed to be put int another post.

try to make new thread...don't hijack others thread :)

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

form1.textbox1.text="abc"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.