Microsoft.VisualBasic

This namespace does contain a lot of the old VB 6.0 runtime functions which you should try and avoid using in a .NET solution.
However this namespace also includes a few new classes, for example the ControlChars which is useful when working with Strings and Characters.


Microsoft.VisualBasic.ControlChars.NewLine


Built-in Functions

Built-in functions that can be called directly in VBA will need to be prefixed with the correct namespace
For example the Abs() function belongs to the System.Maths namespace


Var = System.Math.Abs(-4)


Visual Basic .NET does not use arbitrary statement blocks. Instead, certain keywords that have a specialized terminating statement are used instead of the statement blocks.
In Visual C# .NET, braces ({}) are used to delimit a statement block; otherwise, a single statement is assumed.


Statements in Visual Basic .NET are terminated by the end of the line.
You can use the colon (:) to put multiple statements in a line, and you can use the line continuation (_) character to make a statement span several lines.
Statements in Visual C# .NET are terminated by the semicolon (;).
You can use multiple statements per line, and statements can span multiple lines.


Code is automatically reformatted and realigned in VB but not in C# where you have to press (Ctrl + K), D



VBC#
vbCrlf"\r\n"
System.Environment.NewlineSystem.Environment.NewLine



VBC#
<>!=
Inherits: (colon)
  
MyBase.New(nothing): base (String.Empty)
  
< System.Serializable() >[ System.Serializable ]
  
GetType(this)this.GetType()



http://blogs.msdn.com/gabhan_berry/archive/2008/02/06/excel-s-optional-parameters-and-missing-value-a-c-workaround.aspx
http://msdn.microsoft.com/en-us/vbasic/bb973770.aspx


C# has "default namespace"
VB has "root namespace"


support.microsoft.com/kb/308470
http://dnjonline.com/article.aspx?ID=mar05_vbvscsharp



harding.eduVB.NET / C# Comparison,





Code Completion

For example creating a property in VB.NET you only need to enter the keyword Property and a name and the rest is automatically populated.
In C# you would have to type it all or set up a code snippet.


Upgrading Code

(Tools > Upgrade VB 6.0 Code)
Paste the VBA code into the dialog
Hit Upgrade and paste the .NET code.


VBA Interoperability with Visual Studio Tools for the Office System (3.0)
http://msdn.microsoft.com/en-us/library/bb931201(office.12).aspx
http://msdn.microsoft.com/en-us/library/dd627738(office.12).aspx



Structure replaces Type

Structures can be used in arrays in the same way as custom types are in VBA.
All datatypes expose the Equals() method which is especially useful when using a structure because you can compare two structures without having to compare the individual fields.


There are quite a lot of differences but the main one is the syntax


VBAVisual Basic .NET
Option Base 1Not supported all arrays must start at 0



VB.NET Highlights

  • Not case sensitive

  • Statements are terminated by the end of the line

  • Has a Line Continuation character "_"

  • Adjusts the capitalisation of keywords for consistency

  • Reformats code by logically aligning statements

  • Adds missing end quotes to strings

  • Supplying parentheses to function calls and methods

  • Adds parentheses when declaring subroutines.

  • Has implicit type conversion

  • Has With-EndWith capability making your code less verbose

  • Can use late binding

  • Provides more Intellisense / code completion options

  • Can use optional parameters

  • String concatenation is done using "&"


Microsoft.VisualBasic.Compatibility

When you upgrade a Visual Basic 6.0 project to VB.Net there are a number of items that are impossible to convert across to the Microsoft.VisualBasic namespace.
In this situation this additional namespace has to be used.
These items mimic the Visual Basic 6.0 behaviour while remaining compliant with the Common Language Specification
Whereever possible the upgrade tool within Visual Studio will try and move the code directly to methods in the Microsoft.VisualBasic namespace or System namespace


You should always try and use components from the System namespace if you can but if you really want to you can use he old Visual Basc 6.0 components.
For example the DirListBox, DriveListBox and FileListBox components can all be found in the Microsoft.VisualBasic.Compatibility namespace



Microsoft.VisualBasic.Information





© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited

Top

PrevNext