| | |
how to call another form
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
To call form2 you must to make an object of form2 :
To close form1 after called form2 :
- Don't use Me.Close cause it will close application.
- Use Dispose(), set it to false.
e.g :
VB.NET Syntax (Toggle Plain Text)
Dim MainMenu as New Form2 MainMenu.show
To close form1 after called form2 :
- Don't use Me.Close cause it will close application.
- Use Dispose(), set it to false.
e.g :
VB.NET Syntax (Toggle Plain Text)
Dim MainMenu as New Form2 MainMenu.show Me.Dispose(False)
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
Join Date: Jun 2008
Posts: 17
Reputation:
Solved Threads: 0
•
•
•
•
let us say you have a login button on the registration form which gets enabled on validation of registration details.
code for login button- form2.showdialog()
in the form_load for the 2nd form, do form1.hide()
and in the form closing event for the 2nd form, remember to do form1.close()
thank you so much. It's worked
•
•
Join Date: Aug 2009
Posts: 1
Reputation:
Solved Threads: 0
Hi guys, can you help me in my vb.net project. The problem is that I need to call a form, but I also need to know the form who calls the next form. Because I plan to make an if statement so that the program will know which line of code to execute depending on the form who calls the next form.
It's a database program. And I already have this line of code for the savings account alone. I will need more line of codes for the Dollar and current accounts.
This line of code will read the database. It's a log-in form that accesses the database:
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\Documents and Settings\Student\nrew\db1.mdb;")
Dim cmd As OleDbCommand = New OleDbCommand("Select * from clients where NAME= '" & TextBox1.Text & "' AND PIN = '" & TextBox2.Text & "' ", cn)
cn.Open()
Dim rdr As OleDbDataReader
rdr = cmd.ExecuteReader
If rdr.HasRows Then
rdr.Read()
NoAcc = rdr("NAME")
NoPin = rdr("PIN")
If (TextBox1.Text = NoAcc And TextBox2.Text = NoPin) Then NoAccmod2 = NoAcc
wdb.Show()
Me.Hide()
Else
MsgBox("Incorrect AccountName or PIN", MsgBoxStyle.Critical, "Sorry try again")
TextBox1.Clear()
TextBox2.Clear()
End If
Please help, the only thing I need is to have a reference on what form calls the next form.
It's a database program. And I already have this line of code for the savings account alone. I will need more line of codes for the Dollar and current accounts.
This line of code will read the database. It's a log-in form that accesses the database:
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\Documents and Settings\Student\nrew\db1.mdb;")
Dim cmd As OleDbCommand = New OleDbCommand("Select * from clients where NAME= '" & TextBox1.Text & "' AND PIN = '" & TextBox2.Text & "' ", cn)
cn.Open()
Dim rdr As OleDbDataReader
rdr = cmd.ExecuteReader
If rdr.HasRows Then
rdr.Read()
NoAcc = rdr("NAME")
NoPin = rdr("PIN")
If (TextBox1.Text = NoAcc And TextBox2.Text = NoPin) Then NoAccmod2 = NoAcc
wdb.Show()
Me.Hide()
Else
MsgBox("Incorrect AccountName or PIN", MsgBoxStyle.Critical, "Sorry try again")
TextBox1.Clear()
TextBox2.Clear()
End If
Please help, the only thing I need is to have a reference on what form calls the next form.
•
•
Join Date: Jun 2009
Posts: 271
Reputation:
Solved Threads: 55
in my oppinion the easiest way would be to create an overloaded New and call it with parameter (byval caller as From)
example:
and call the new form like
example:
vb Syntax (Toggle Plain Text)
Public Sub New(ByVal caller As Form) InitializeComponent() Select Case caller.Name Case "Form2" Case "Form1" Case Else End Select End Sub
and call the new form like
Dim formtest As New Form1(Me) ![]() |
Similar Threads
- calling sub from a different form (VB.NET)
- Control or Object (Other than MDI Form) In vb 6.0 which can hold a Form (Visual Basic 4 / 5 / 6)
- Retrieving form name (Visual Basic 4 / 5 / 6)
- Linking Multiple Form together (VB.NET)
- Calling a Dynamic form (VB.NET)
- loadin a form (Visual Basic 4 / 5 / 6)
- I GIVE UP, how do I modify this code to call from one form to the other and back (C++)
- Dialog Box alongwith Form (Visual Basic 4 / 5 / 6)
Other Threads in the VB.NET Forum
- Previous Thread: how to clear the item listview when triggering a button
- Next Thread: Problem by writting the sql statement
Views: 9333 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2005 2008 access account application array arrays basic bing button buttons c# center check checkbox code convert crystalreport data database datagrid datagridview date design designer dissertation dissertations dropdownlist excel fade file-dialog filter ftp generatetags google gridview hardcopy images inline input insert installer intel internet listview mobile monitor net networking objects output panel passingparameters picturebox port position print printing problem read remove save searchbox searchvb.net select serial shutdown soap sorting studio survey table tcp temperature text textbox time timer timespan toolbox trim update user validation vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet visual visualbasic visualbasic.net visualstudio2008 web webbrowser winforms wpf year






