Problem with classes

Joined
Sep 15, 2005
Messages
5
Programming Experience
Beginner
Problem with classes [RESOLVED]

Hi All.

Sorry to bug you with a beginners question but I am trusting there is somebody sympathetic to newbies out there. (I haven't written code since my old Turbo C++ days so maybe you can't teach an old dog new tricks...but who knows)

I am using a book from Sybex called Mastering Visual basic.NET and it gives an example on learning the basics of Classes.

Step1.
Create a class called Mininmal. It doesn't do anything its just to show how it works.
Step2.
Add a button to the form and in the Click Event Handler add this code:

Dim obj1 AS NEW Minimal ()
Console.WriteLine(obj1.ToString)
Console.WriteLine(obj1.GetHashCode)
etc...

My problem is that when I type this and try to type in the two brackets () after Minimal and press enter, the brackets disappear and I end up with:
Dim obj1 AS NEW Minimal
which of course means the instance of the Minimal class is stored in the obj1 variable, as I understand it, and I don't get any of the inherited methods I need.
What do I not understand? If I use the code example from the CD that comes with the book it works fine, but if I try to type it in myself the brackets disappear and I cannot get the same code.
I would be grateful for any help.
many thanks
Jeremy
 
Last edited:
in VB braces "()" are used to indication parameters (send arguements) so subs, functions, etc...

most of the time VB will add the braces even if there arnt any arguements to be passed but on occasion the braces wont be there but they will always be there if data is being passed to the sub/function so no need to worry about whether the braces are there or not if nothing's being passed anyways
 
The VB.NET IDE does various things for you with regards to formatting and that is one of them. You can actually turn that setting off in the VS options, but you'll lose other things too. It's under Options -> Text Editor -> Basic -> VB Specific -> Pretty listing if you're interested.
 
Back
Top