Hi I Need Help about using Visual Basic 6 2013
How do you make buttons go to other windows?

Dani AI

Generated

: the first thing to clear up (as already asked) is which “Visual Basic” is actually in use. Projects with .vbp/.frm are classic VB6; projects with .sln/.vbproj (and opened in Visual Studio 2012/2013/etc.) are VB.NET. That difference changes the exact code and best practice.

For VB6 the usual pattern is to open a second form from the button’s Click handler. Two common choices are using the default form instance or creating an explicit instance, and whether the new window is modal (blocks the caller) or modeless. Example patterns (names changed from the thread) — set a public property on the second form and show it modally:

' In frmDetails:
Public ItemID As Long

' In frmMain:
Private Sub btnOpen_Click()
    Dim f As New frmDetails
    f.ItemID = 42
    f.Show vbModal
End Sub

For VB.NET (Visual Studio), use ShowDialog for modal or Show for modeless, prefer creating instances instead of relying on defaults, and use a Using block or check Application.OpenForms to avoid multiple copies:

Private Sub btnOpen_Click(sender As Object, e As EventArgs) Handles btnOpen.Click
    Using dlg As New DetailsForm()
        If dlg.ShowDialog() = DialogResult.OK Then
            Dim result = dlg.SelectedValue
        End If
    End Using
End Sub

Troubleshooting notes (build on ’s quick example): confirm the Click handler is actually wired to the button (double‑click control in the IDE to generate it), ensure the target form is included in the project, avoid default control names like Command1, and set breakpoints to see whether the handler runs. If the goal is to pass data back, prefer properties or return values (modal dialog) rather than globals.

Recommended Answers

All 2 Replies

Hi

What version of Visual Basic are you using? You have posted in the VB 6 forum but mention Visual Basic 6 2013 so wondering if you are in fact using VB.NET?

Also, can you clarify what you mean by making buttons go to other windows? Do you mean, how do I show another form (window) when I click a button or do you mean something else entirely?

if you are using vb6, then just design the button1 on form1 and then insert another form named form2, double click on button1 and copy and paste the code there.

Option Explicit
Private Sub Command1_Click()
Form2.Show
End Sub

now run your app and see the result.
Regards,

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.