473,395 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Form.Show C# vs VB.NET (2005)

Hi.

Try this:
Create a new VB.NET windows application and put on button on the form. Now add a new form to the project (Form2) and in the Click event handler of the button from the first form put this code:
Form2.Show()

It will work, and when you click it, the second form will be shown, but only one instance, no matter how many times you click the button.


Now do the exact same steps, but with a C# application. It doesn't work...
The compiler will report an error at the line "Form2.Show();", saying "An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Control.Show()".

Why is that? Shouldn't VB.NET and C# have the same capabilities? puzzled...
Jul 22 '08 #1
4 2403
r035198x
13,262 8TB
They have same capabilities but they are different beasts.
The syntax for C# is different (closer to Java). For that example the Show method is non-static and so cannot be referenced without an object instance.
Jul 22 '08 #2
For that example the Show method is non-static and so cannot be referenced without an object instance.
And how come it works in VB.NET? Because I didn't instantiate an object of type Form2 anywhere...
Jul 22 '08 #3
r035198x
13,262 8TB
And how come it works in VB.NET? Because I didn't instantiate an object of type Form2 anywhere...
<What I really want to say is that because VB is crap.>
You'd have to check the scoping rules for VB.
<What I really want to say is that because VB is crap./>
Jul 22 '08 #4
Plater
7,872 Expert 4TB
And how come it works in VB.NET? Because I didn't instantiate an object of type Form2 anywhere...
I am really surprised that VB allowed that to happen. Seems poor implementation on the part of VB.
Jul 22 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: david | last post by:
Hi, I have a form with 2 select objects which are not linked together in any way. The list exactly the same information. The code that generates the data is: ...
4
by: Stuart Perryman | last post by:
Hi, I have the following code which works just fine in IE6 but not in Firefox. It is an extract of several table rows each with an individual form. It is generated by php. <form...
0
by: alwayshouston | last post by:
Hi All, I am stuck on designing a form for small application. My application has three tables as follow: Table 1: tblStock (table name) Stock_ID; Stock_Start_Date; Stock_End_Date (field name)...
4
by: Tull Clancey | last post by:
I have a class that inherits a form. How can I handle clicks and changes to controls on the inherited form within my class? Cheers, Tull.
3
by: gsb58 | last post by:
Hi! A mainform is being used to show records from a table in an sql database. A button on the main form will load a new form that allows the user to add, delete, update and search certain...
1
by: James | last post by:
CWinFormsDialog in .net 2.0 lets you host a .Net UserControl as a dialog in a managed C++ MDI application. I.e. in the sample: ----------------------------------------------- #include...
0
by: Miro | last post by:
Something I have run into using VB Express 2005 with mdi forms. I have not been able to re-create this but I'll let out the information on how I came about fixing this. As it cost me about 4...
6
by: Goran Djuranovic | last post by:
Hi all, I have a VB.NET windows application that uses MDI form. When I try to delete a datagrid row from one of the MDI children forms, I use a MessageBox YesNo confirmation, which, after confirmed,...
5
by: BD | last post by:
I am coding with C# in Visual Studio 2005 for a database application residing on remote MS SQL Server 2005. What I want to do is open the same form but from 2 different places and only one...
7
by: Jwe | last post by:
Hi, I've written a program which has both a command line interface and Windows form interface, however it isn't quite working correctly. When run from command line with no arguments it should...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.