Understanding VB.NET Code

1. Option Explicit: Used at file level to force explicit declaration of all variables in that file.

When Option Explicit appears in a file, you must explicitly declare all variables using the Dim, Private, Public, or ReDim statements. If you attempt to use an undeclared variable name, an error occurs at compile time.

If you don’t use the Option Explicit statement, all undeclared variables are of Object type.

VBA: Option Explicit

VB.NET: Option Explicit On

Reference: http://msdn.microsoft.com/en-us/library/y9341s4f(v=vs.71).aspx

2. Declare Statement: Used at module level to declare references to external procedures in a dynamic-link library (DLL).

[Public | Private] Declare Function name Lib “libname” [Alias “aliasname”] [([arglist])] [As type]

Reference: http://msdn.microsoft.com/en-us/library/aa243324(v=vs.60).aspx

VBA: ByVal field As Any

VB.Net: ByVal field As Object

Reference: http://social.msdn.microsoft.com/Forums/en/vbinterop/thread/2c87df7c-48ad-4ab8-a6b8-e0e277eb74ec

3. Radio Buttons (or Option Buttons)

VBA: RadioButton.Value

VB.NET: RadioButton.Checked

When grouped under a GroupBox, users will only be able to select one radio button.

4. Common Dialogue

FileOpenDialog.Filter

VBA:  .. +  “Microstation files (*.dgn)|*.DGN|”

VB.NET:   .. + “Microstation files (*.dgn)|*.DGN”

Note that vb.net does not allow a vertical bar at the end of the very last one of the Filter Options

5. Left and Right Function

In VB.NET, add:

Imports VBStrings = Microsoft.VisualBasic.Strings

and use

VBStrings.Left

 

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: