Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

new to VB.NET but I know C#

Status
Not open for further replies.

dragonwell

Programmer
Oct 21, 2002
863
US
I need to get up to speed fast on the VB.NET syntax and usage. I have been programming with C# for the past two years and have never wirtten more than a couple lines of VB!

Could someone summarize the basic differences that I might be concerned with (or give a link)?

I know the "really basic" stuff like the ";" is not used, but what about class definitions, properties, keyword are differnet, etc? What's this "Dim" business and can I use "Private" instead?

Thanks!
 
Well, lets see

If you declare a variable as private, you don't use "Dim."

Another thing to remember is that most things have a declaration and an end declaration. For example, "Class xyz.....End Class".

You'll figure out propertiers pretty easy. In the IDE, try typing the following and press enter: Public Property MyProperty As String. It will put a few lines of code in there for you, and its self explanitory.

Another, subtle difference, is that you use parentheses instead of square brackets for array elements.

There is also a lot of stuff held over from VB 6. For example, while you can still write and read to the registry in much the same way as C#, you can use the SaveSetting() and GetSetting() functions as a quick way to write to the registry. These settings go under your "VB and VBA Programs" in the registry.

You can also use tools such as this to try and translate code:

 
hi..

actually in VB.net
dim and private could mean the same thing inside a class or module..

but anyhow heres a comprehensive list of declarations and assignments..

dim inside a proc means a local var

dim in class/module menas the same

dim inside a structure menas a private

public is always public aka globals

static retian values in procedures

hope this helps:
jes
 
Dim is short for "dimension" as in "assign dimensions to an array" and utimately means "allocate storage and assign a data type" whether for an array or not.

It has nothing to do with setting the brightness of lamps, despite the connotation. ;-)

The other variants of Dim (such as Private/Public/etc.) are the same thing, but also assign certain storage class or scoping attributes.
 
Ok - starting my fisrt VB.NET project.

1. When I add a new class file, the namespace is not included (or is it?). How can I turn that on.

2. I would like "Imports System" to be part of the default class template. Will this require editing the ncew class template or is it jsut a checkbox burried in the settings somewhere?

Also, am I justified in wanting these things, or is it just because of my C# background that I want them and I should learn to get used to the VB.NET defaults?

Thanks!!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top