unable to switch between different forms...

santosh

New member
Joined
Aug 1, 2005
Messages
3
Programming Experience
1-3
I m facing this problem..i m finding myself unable to move amongst different vb forms..help me.?

this was the error i got :

C:\Documents and Settings\Santosh Singh Rawat\My Documents\Visual Studio Projects\PayRoll\PayRoll_Main.vb(163): Reference to a non-shared member requires an object reference.

regards,
Santosh
 
Your post does not explain the problem! Please specify.

If you are talking about switching forms use show() and hide methods.

To call form use: FORMNAME.Show(FORMOPENER)
To hide form use: FORMNAME.Hide(FORMOPENER)
 
Dear Manicshaw and kulrom...

thanx a lot for help..
I m designing a payroll system...for my company..
In that i m having a main frame and in that frame 6 command buttons to switch between different different forms...

here is the code..

*****************************************************
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

PayRoll_Main.Hide()

Emp_Det.Show()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

PayRoll_Main.Hide()

Emp_PaySlip.Show()

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

PayRoll_Main.Hide()

Emp_SalDet.Show()

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

CrystalReport3.Action = 0

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

PayRoll_Main.Hide()

Emp_YearDet.Show()

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

End

End Sub

******************************************************

here is the error generated....look at the last error..

C:\Documents and Settings\Santosh Singh Rawat\My Documents\Visual Studio Projects\PayRoll\PayRoll_Main.vb(163): Reference to a non-shared member requires an object reference.

C:\Documents and Settings\Santosh Singh Rawat\My Documents\Visual Studio Projects\PayRoll\PayRoll_Main.vb(164): Reference to a non-shared member requires an object reference.

C:\Documents and Settings\Santosh Singh Rawat\My Documents\Visual Studio Projects\PayRoll\PayRoll_Main.vb(168): Reference to a non-shared member requires an object reference.

C:\Documents and Settings\Santosh Singh Rawat\My Documents\Visual Studio Projects\PayRoll\PayRoll_Main.vb(169): Reference to a non-shared member requires an object reference.

C:\Documents and Settings\Santosh Singh Rawat\My Documents\Visual Studio Projects\PayRoll\PayRoll_Main.vb(173): Reference to a non-shared member requires an object reference.

C:\Documents and Settings\Santosh Singh Rawat\My Documents\Visual Studio Projects\PayRoll\PayRoll_Main.vb(174): Reference to a non-shared member requires an object reference.

C:\Documents and Settings\Santosh Singh Rawat\My Documents\Visual Studio Projects\PayRoll\PayRoll_Main.vb(178): 'Action' is not a member of 'PayRoll.CrystalReport3'.

C:\Documents and Settings\Santosh Singh Rawat\My Documents\Visual Studio Projects\PayRoll\PayRoll_Main.vb(182): Reference to a non-shared member requires an object reference.

C:\Documents and Settings\Santosh Singh Rawat\My Documents\Visual Studio Projects\PayRoll\PayRoll_Main.vb(183): Reference to a non-shared member requires an object reference.

'Sub Main' was not found in 'PayRoll.Form1'.


reagards,
Santosh.
 
Your error is exactly what the message says. In object-oriented programming you need to create an object before you can use its properties and methods. OOP mimics real life. To do something with an object in real life you actually have to have an instance of that object. You can't just say Fridge.Open() and expect something to happen. You actually have to a particular fridge in front of you before you can use it Open method. Same thing in OOP. When you design a form in the IDE, you are creating a class. It is not a single, specific form. You can actually create as many instances of that class as you like. You must create an object before you can use the properties and methods of that object. This is the absolute foundation of OOP. I suggest you do some reading on the basics.
 
Switch between different forms

you must instantiate the form object to move from one form to another.
suppose you have two forms namely :

1) form1
2) from2

if you are on form1 and want to switch to form2 at runtime then you must add the following code in the eventhandler.

dim ObjForm as new form2
ObjForm.Show()
 
hi jmcilhinney and nakracreative,

thanks a lot for helps...i finally corrected the error...but stll got this error..

VB.NET:
C:\Documents and Settings\Santosh Singh Rawat\My Documents\Visual Studio Projects\PayRoll\PayRoll_Main.vb(183): 'Action' is not a member of 'PayRoll.CrystalReport3'."[\code]
 
action is not supposed to be a member of crystalreport3.
 
i know oops concept and know C++ and java a little bit C# too almost similar to java...but as tis is my 1st project so some what confused..
 
regards,
 
Santosh
 
santosh said:
PrivateSub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

CrystalReport3.Action = 0

EndSub
Here's a quote from your code. Is Action a member or not? If it isn't, as the error message suggets, then you can't use it like this.
 
Back
Top