Hi guys,

Im pretty new to vb .net. What im trying to do it I have 2 forms.

First of all I have created a Module with the code:
Module Module1

Public Start As New Form1
Public Input As New Form2

Public Sub main()
Application.Run(Input)
End Sub


Form1 has a button which when pressed opens Form2 which is ok but it just doesnt close down Form1. I have also tried using Form1.hide(), same results with this too.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form2.Show()
Form1.Close()

I've tried searching the net but I cant find anyone else who has this problem...

try this recovery :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
         Form2.Show()
        Me.Dispose(False)
End Sub

It switches between the forms but only after 4 times of switching... I think it finds some kind of error at this point...

why u didn't use start and input?that it work when you used form1.show or form2.close?
i think it did not worked.

Hi
Why dont you try me.hide() instead of giving form1.Hide() or form1.Close()

private sub button1.click()
form2.show()
me.hide()

he was tried it suganzeni...

Oh K fine.
Do you have any idea why this problem occurs.

i just confused when see his code, he declare input and start but didn't used it to call form.

Aren't Start and Input reserved words in .NET?

nope..i m using .net 2003. i didn't know in higher version.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm1 As Form
frm1 = frmInput
frm1.Show()
Me.Hide()
End Sub

This is in your "Start" Form in the button1 click event

Private Sub frmInput_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
Dim frm As Form
frm = frmStart
frmStart.show()
End Sub

This is in your form Input closed form event, to show your form1 Start

Dim frm As Form
frm = frmStart
frmStart.show()

it should be : frm.show()

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.