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.


Built-in Functions

Built-in functions that can be called directly in VBA will need to be prefixed with the correct namespace
VB.Net does not use arbitrary statement blocks. Instead, certain keywords that have a specialized terminating statement are used instead of the statement blocks.
In C# braces ({}) are used to delimit a statement block; otherwise, a single statement is assumed.


Statements in VB.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#
<>!=
Inherits: (colon)
  
MyBase.New(nothing): base (String.Empty)
  
< System.Serializable() >[ System.Serializable ]
  
GetType(this)this.GetType()

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



VBA Interoperability with Visual Studio Tools for the Office System (3.0)
link - learn.microsoft.com/en-us/previous-versions/office/developer/office-2007/bb931201(v=office.12)


Chapter 4: Moving from VBA to VSTO and Visual Basic
link - learn.microsoft.com/en-us/previous-versions/office/developer/office-2007/dd627739(v=office.12)


Chapter 12: Migrating VBA Solutions to VSTO
link - learn.microsoft.com/en-us/previous-versions/office/developer/office-2007/dd627738(v=office.12)


Structure replaces Type

Structures can be used in arrays in the same way as custom types are in VBA.
All data types 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



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





© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext