Hi all.

I would like to know how can I code form1 to open form2 immediately when form1 loaded in Visual Basic?

eg. Form1 opens and immediately form2 opens.

This is almost like website redirection.


You call and initiate the second form, from the first forms load event:

Sub Form1_Onload ( byval sender as object, byval e as system.eventargs) Handles Form1.OnLoad
    dim NewForm as new Form2
End Sub

Using this technique, you can even set values of controls (or add new controls,) in the second form.

dim NewForm as new form2
'assume there is a textbox txtEntry on Form2
NewForm.txtEntry.Text ="Hello I'm on Form 2" 
NewForm.Show() 'Form2 will open with the textbox populated

You can even open the second form as a modal dialog and process results.

Dim NewForm as New Form2

If NewForm.ShowDialog = DialogResult.OK then
    'Result of OK was returned
    'Other Result
end if

On your second form you would probably have a button that would set the dialog result of the form to OK provided what you wanted to happen on the form happened.

simply just paste the code in the form 1 load event
if you want to load as dialog then put this code:
and as to create new form from form 1 then

Dim Nform as new Form
Nform.text = "Form2: Title"

You have done.
if this is not your question then please elaborate this

hi i hope it could be help you

1.Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
2 Form2.Show()
3 Form2.WindowState = FormWindowState.Normal
4 Form2.BringToFront()
5 End Sub

by: Rossana kaw

Can you tell whether this discussion solve your quries or not?
if yes then please mark it as solve
if not then tell what you don't get it