| |
KB Article |
|
|
Mike Prestwood
|
1. A 10 Minute VB.Net Console Application Quick Start
This will show how to make a "hello world" console application in Visual Studio 2008 using VB.Net.
55 months ago, and updated 28 months ago
(9 Comments
, last by Anonymous )
|
 Article
 18219 Hits
|
 VB.Net Language
|
Mike Prestwood
|
2. A 10 Minute VB.Net Winforms Quick Start
The ButtonsVB project. Create a classic "Hello, World" application using Visual Studio .Net with VB.Net syntax. Requires either the full version or VB.Net Express Edition.
59 months ago, and updated 53 months ago
|
 Article
 3471 Hits
|
 VB.Net Language
|
Bryan Valencia
|
3. ASP.NET Cheat Sheet
Here's some copy-and-paste code that I use weekly. Bookmark it and save yourself hours!
|
 KB Post
 2139 Hits
|
 VB.Net Language
|
Stephen Berry
|
4. Associative Arrays in Visual Basic (a Dictionary)
An associative array links a set of keys to a set of values. In Visual Basic, associative arrays are implemented as Dictionaries.
This code produces a message box saying "Nevada."
59 months ago, and updated 54 months ago
|
 Code
 8472 Hits
|
 VB.Net Language
|
Mike Prestwood
|
5. Run a Program in VB.Net
How do you launch a Windows application in VB.Net? How do I open the default browser to a specific URL?
|
 FAQ
 5262 Hits
|
 VB.Net Language
|
Wes Peterson
|
6. Telerik Extensions for ASP.NET MVC - Free
http://www.telerik.com/products/aspnet-mvc.aspx?utm_source=CodeProjectNewsletter&utm_medium=banner&utm_campaign=MVC_Jan15
|
 Link
 3581 Hits
|
 VB.Net Language
|
Mike Prestwood
|
7. VB.Net Abstraction (MustInherit, MustOverride, Overrides)
VB.Net supports abstract class members and abstract classes using the MustInherit and MustOverride modifiers.An abstract class is indicated with a MustInherit modifier and is a class with one or more abstract members and you cannot instantiate an abstract class. However, you can have additional implemented methods and properties. An abstract member is either a method (implicitly virtual), property, indexer, or event in an abstract class. You can add abstract members ONLY to abstract classes using the MustOverride keyword. Then you override it in a descendant class with Overrides.
55 months ago, and updated 51 months ago
|
 Code |
 Article |
 7250 Hits
|
 VB.Net Language
|
Mike Prestwood
|
8. VB.Net Access Modifiers
In VB.Net, you specify each class and each class member's visibility with an access modifier preceding class or member. The VB.Net access modifiers are the traditional Public, Protected, and Private plus the two additional .Net modifiers Friend and Protected Friend.
Friend indicates members are accessible from types in the same assembly. Protected Friend indicates members are accessible from types in the same assembly as well as descendant classes. OO purist might object to Friend and Protected Friend and I suggest you avoid them until you both fully understand them and have a need that is best suited by them.
53 months ago, and updated 51 months ago
|
 Code
 3638 Hits
|
 VB.Net Language
|
Mike Prestwood
|
9. VB.Net Assignment (=)
Languages Focus: AssignmentCommon assignment operators for languages include =, ==, and :=. An assignment operator allows you to assign a value to a variable. The value can be a literal value like "Mike" or 42 or the value stored in another variable or returned by a function. VB.Net AssignmentVB.Net uses = for it's assignment operator.
55 months ago, and updated 53 months ago
|
 Code
2532 Hits
|
 VB.Net Language
|
Mike Prestwood
|
10. VB.Net Associative Array (Dictionary)
An associative array links a set of keys to a set of values. In Visual Basic, associative arrays are implemented as Dictionaries.
This code produces a message box saying "Nevada."
54 months ago, and updated 52 months ago
|
 Code
7390 Hits
|
 VB.Net Language
|
Mike Prestwood
|
11. VB.Net Base Class (System.Object)
In VB.Net, the Object keyword is an alias for the base System.Object class and is the single base class all classes ultimately inherit from.
55 months ago, and updated 52 months ago
|
 Code
4651 Hits
|
 VB.Net Language
|
Mike Prestwood
|
12. VB.Net Case Sensitivity (No)
VB.Net is not case sensitive. If you type any other case for commands or variables, VB.Net will change it to the accepted or defined case. For example, if you type messagebox.show it is converted to MessageBox.Show.
55 months ago, and updated 52 months ago
|
 Code
2435 Hits
|
 VB.Net Language
|
Mike Prestwood
|
13. VB.Net Class..Object (Class..End Class..New)
Declare and implement VB.Net classes after the form class or in their own .vb files. Unlike VB Classic, you can have more than one class in a .vb class file (VB classic uses .cls files for each class).
55 months ago, and updated 52 months ago
|
 Code |
 KB Post |
 3682 Hits
|
 VB.Net Language
|
Mike Prestwood
|
14. VB.Net Code Blocks (End Xxx)
VB.Net, like VBClassiccode blocks, are surrounded by statement ending keywords that all use End such as End Class, End Sub, End Function, End If, and End If.
54 months ago, and updated 52 months ago
|
 Code
 2503 Hits
|
 VB.Net Language
|
Mike Prestwood
|
15. VB.Net Comments (' or REM)
Languages Focus: CommentsCommenting code generally has three purposes: to document your code, for psuedo coding prior to coding, and to embed compiler directives. Most languages support both a single line comment and a multiple line comment. Some languages also use comments to give instructions to the compiler or interpreter.
VB.Net Comments Commenting Code VB.Net, like all the VB-based languages, uses a single quote (') or the original class-style basic "REM" (most developers just use a quote). VB.Net does NOT have a multiple line comment.
54 months ago, and updated 52 months ago
(1 Comments
, last by Anonymous )
|
 Code
6092 Hits
|
 VB.Net Language
|
Mike Prestwood
|
16. VB.Net Comparison Operators (=, <>)
Same as VB Classic.
|
 Code
4195 Hits
|
 VB.Net Language
|
Mike Prestwood
|
17. VB.Net Constants (Const kPI Double = 3.1459)
In VB.Net, you define constants with the Const keyword.
All constants are part of a class (no global constants) but you can make a constant public and have access to it using ClassName.ConstantName so long as you have added the class to the project. This works even without creating the class as if the public constants were static, but you cannot use the Shared keyword.
Constants must be of an integral type (sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, decimal, bool, or string), an enumeration, or a reference to null.
53 months ago, and updated 43 months ago
|
 Code
4413 Hits
|
 VB.Net Language
|
Mike Prestwood
|
18. VB.Net Constructors (New)
A sub named New. You can overload the constructor simply by adding two or more New subs with various parameters. Public Class Cyborg Public CyborgName As String Public Sub New(ByVal pName As String) CyborgName = pName End Sub End Class
|
 Code |
 KB Post |
4684 Hits
|
 VB.Net Language
|
Mike Prestwood
|
19. VB.Net Custom Routines (Sub, Function)
VB.Net is a fully OOP language so both Subs and Functions are methods of a class. A Sub does not return a value while a Function does.
54 months ago, and updated 53 months ago
|
 Code
2306 Hits
|
 VB.Net Language
|
Mike Prestwood
|
20. VB.Net Deployment Overview
VB.Net projects require the .Net framework and any additional dependencies you've added such as Crystal Reports.
In Visual Studio.Net, you can create a Setup and Deployment project by using any of the templates available on the New Project dialog (Other Project Types).
In addition, VB.Net projects also support ClickOnce which brings the ease of Web deployment to Windows Forms and console applications. To get started, right click on your solution in the Solution Explorer, click Properties then select the Security tab.
In addition, you can use any of the many free and commercially available installation packages.
(1 Comments
, last by Anonymous )
|
 Code
3000 Hits
|
 VB.Net Language
|
Mike Prestwood
|
21. VB.Net Development Tools
Languages Focus: Development ToolsPrimary development tool(s) used to develop and debug code.
VB.Net Development ToolsMicrosoft Visual Basic Express Editions (as in Visual Basic 2008 Express Edition) and the full version of Microsoft Visual Studio.Net are the current primary tools. VB.Net is not compatible with VB Classic.
54 months ago, and updated 52 months ago
|
 Code
3178 Hits
|
 VB.Net Language
|
Mike Prestwood
|
22. VB.Net Empty String Check (String.IsNullOrEmpty)
The .Net framework offers a static method in the string class: String.IsNullOrEmpty.
|
 Code
5898 Hits
|
 VB.Net Language
|
Mike Prestwood
|
23. VB.Net End of Statement (Return)
Languages Focus: End of StatementIn coding languages, common End of statement specifiers include a semicolon and return (others exist too). Also of concern when studying a language is can you put two statements on a single code line and can you break a single statement into two or more code lines.
VB.Net End of StatementA return marks the end of a statement and you cannot combine statements on a single line of code. You can break a single statement into two or more code lines by using a space and underscore " _".
53 months ago, and updated 52 months ago
|
 Code
2814 Hits
|
 VB.Net Language
|
Mike Prestwood
|
24. VB.Net Exception Trapping (Try...Catch...Finally)
A common usage of exception handling is to obtain and use resources in a "try-it" block, deal with any exceptions in an "exceptions" block, and release the resources in some kind of "final" block which executes whether or not any exceptions are trapped.
54 months ago, and updated 53 months ago
(1 Comments
, last by Anonymous )
|
 Code
3991 Hits
|
 VB.Net Language
|
Mike Prestwood
|
25. VB.Net File Extensions
Common source code file extensions include:
- .SLN - Solution File. Contains solution specific information such as links to the projects within this solution.
- .VBPROJ - VB.Net Project File. Contains project specific information.
- .VB -VB.Net source file.
- .Designer.VB -VB.Net form file (a text resource file).
52 months ago, and updated 52 months ago
|
 Code
 2486 Hits
|
 VB.Net Language
|
Mike Prestwood
|
26. VB.Net Finalizer (Finalize())
Use a destructor to free unmanaged resources. A destructor is a method with the same name as the class but preceded with a tilde (as in ~ClassName). The destructor implicity creates an Object.Finalize method (you cannot directly call nor override the Object.Finalize method).
In VB.Net you cannot explicitly destroy an object. Instead, the .Net Frameworks garbage collector (GC) takes care of destroying all objects. The GC destroys the objects only when necessary. Some situations of necessity are when memory is exhausted or you explicitly call the System.GC.Collect method. In general, you never need to call System.GC.Collect.
52 months ago, and updated 51 months ago
|
 Code |
 Article |
5391 Hits
|
 VB.Net Language
|
Mike Prestwood
|
27. VB.Net If Statement (If..ElseIf..Else..End If)
Same as VB classic.
55 months ago, and updated 52 months ago
|
 Code
2828 Hits
|
 VB.Net Language
|
Mike Prestwood
|
28. VB.Net Inheritance (Inherits ParentClass)
VB.Net uses the Inherits keyword followed by the parent class name. If you do not include Inherits, your class inherits from System.Object.
55 months ago, and updated 52 months ago
|
 Code
3893 Hits
|
 VB.Net Language
|
Mike Prestwood
|
29. VB.Net Inheritance-Multiple (Not Supported)
VB.Net does not support multiple implementation inheritance. Each class can have only one parent class (a single inheritance path). In VB.Net, you can use multiple interface usage to design in a multiple class way horizontally in a class hierarchy.
55 months ago, and updated 52 months ago
|
 Code
 2130 Hits
|
 VB.Net Language
|
Mike Prestwood
|
30. VB.Net Inlining (Automatic)
In VB.Net, inlining is automatically done for you by the JIT compiler for all languages and in general leads to faster code for all programmers whether they are aware of inlining or not.
|
 Code
2741 Hits
|
 VB.Net Language
|
Mike Prestwood
|
31. VB.Net Interfaces (Interface, Implements)
With VB.Net you define an interface with the Interface keyword and use it in a class with the Implements keyword. In the resulting class, you implement each property and method and add Implements Interface.Object to each as in: Sub Speak(ByVal pSentence As String) Implements IHuman.Speak MessageBox.Show(pSentence) End Sub
55 months ago, and updated 51 months ago
|
 Code |
 Article |
 4030 Hits
|
 VB.Net Language
|
Mike Prestwood
|
32. VB.Net Left of Substring (Left or Substring)
The above usage of Left and Substring are equivalent.
Left is a traditional VB approach popular with developers moving from VB Classic to VB.Net. Substring is considered the .Net way of doing string manipulation.
55 months ago, and updated 54 months ago
|
 Code
 7589 Hits
|
 VB.Net Language
|
Mike Prestwood
|
33. VB.Net Literals (quote)
A value directly written into the source code of a computer program (as opposed to an identifier like a variable or constant). Literals cannot be changed. Common types of literals include string literals, floating point literals, integer literals, and hexidemal literals. Literal strings are usually either quoted (") or use an apostrophe (') which is often referred to as a single quote. Sometimes quotes are inaccurately referred to as double quotes. Languages Focus: LiteralsIn addition to understanding whether to use a quote or apostrophe for string literals, you also want to know how to specify and work with other types of literals including floating point literals. Some compilers allow leading and trailing decimals (.1 + .1), while some require a leading or trailing 0 as in (0.1 + 0.1). Also, because floating point literals are difficult for compilers to represent accurately, you need to understand how the compiler handles them and how to use rounding and trimming commands correctly for the nature of the project your are coding. VB.Net LiteralsString literals are quoted as in "Prestwood". If you need to embed a quote use two quotes in a row.
To specify a floating point literal between 1 and -1, preceed the decimal with a 0. If you don't, the compiler will auto-correct your code and place a leading 0. It will change .1 to 0.1 automatically. Trailing decimals are not allowed.
54 months ago, and updated 52 months ago
|
 Code
3668 Hits
|
 VB.Net Language
|
Mike Prestwood
|
34. VB.Net Logical Operators
VB.Net logical operators:
| And |
and, as in this and that |
| Or |
or, as in this or that |
| Not |
Not, as in Not This |
| Xor |
either or, as in this or that but not both |
|
 Code
3587 Hits
|
 VB.Net Language
|
Mike Prestwood
|
35. VB.Net Member Field
In VB.Net you can set the visibility of a member field to any visibility: private, protected, public, friend or protected friend.
You can intialize a member field with a default when declared. If you set the member field value in your constructor, it will override the default value.
Finally, you can use the Shared modifier (no instance required) and ReadOnly modifier (similar to a constant).
53 months ago, and updated 43 months ago
|
 Code |
 Article |
 2999 Hits
|
 VB.Net Language
|
Mike Prestwood
|
36. VB.Net Member Method (Sub, Function)
VB.Net uses the keywords sub and function. A sub does not return a value and a function does. Many programmers like to use the optional call keyword when calling a sub to indicate the call is to a procedure.
53 months ago, and updated 52 months ago
|
 Code
 2625 Hits
|
 VB.Net Language
|
Mike Prestwood
|
37. VB.Net Member Modifiers
The method modifiers include MustOverride, NotOverridable, Overridable, Overrides. Specify VB.Net member modifiers as follows:
Public Overrides Function SomeFunction() As Double
The field modifiers include ReadOnly and Shared. Specify field modifiers as follows:
Public ReadOnly SomeField As String
|
 Code
 2805 Hits
|
 VB.Net Language
|
Mike Prestwood
|
38. VB.Net Member Property (property, get, set)
VB.Net uses a special property keyword along with special get and set methods to both get and set the values of properties. For a read-only property, leave out the set method. The value keyword is used to refer to the member field. Properties can make use of any of the access modifiers (private, protected, etc).
My preference for VB.Net code is to start member fields with "F" ("FName" in our example) and drop the "F" with properties that manage member fields ("Name" in our example).
53 months ago, and updated 52 months ago
|
 Code |
 KB Post |
 8428 Hits
|
 VB.Net Language
|
Mike Prestwood
|
39. VB.Net Overloading (Overloads, or implicit)
VB.Net supports both method and operator overloading.
For method overloading, you either use implicit overloading (no special syntax like C#) or use the Overloads keyword. If you use the Overloads keyword, all overloaded methods with the same name in the same class must include the Overloads keyword.
55 months ago, and updated 43 months ago
|
 Code
4415 Hits
|
 VB.Net Language
|
Mike Prestwood
|
40. VB.Net Overriding (Overridable, Overrides)
In VB.Net, you specify a virtual method with the Overridable keyword in a parent class and extend (or replace) it in a descendant class using the Overrides keyword.
Use the base keyword in the descendant method to execute the code in the parent method, i.e. base.SomeMethod().
(1 Comments
, last by Anonymous )
|
 Code |
 Article |
 8143 Hits
|
 VB.Net Language
|
Mike Prestwood
|
41. VB.Net Overview and History
Language Overview: VB.Net is an OOP language (no global functions or variables). You code using a fully OOP approach (everything is in a class).
Target Platforms: VB.Net is most suitable for creating any type of application that runs on the .Net platform. This includes desktop business applications using WinForms and websites using WebForms.
53 months ago, and updated 52 months ago
|
 Code
 2492 Hits
|
 VB.Net Language
|
Mike Prestwood
|
42. VB.Net Parameters (ByVal, ByRef)
By Reference or Value For parameters, you can optionally specify ByVal or ByRef. ByVal is the default if you don't specify which is changed from VB Classic (in VB Classic, ByRef was the default).
54 months ago, and updated 52 months ago
|
 Code
2574 Hits
|
 VB.Net Language
|
Mike Prestwood
|
43. VB.Net Partial Classes (Partial)
VB.Net supports both partial classes and partial methods.
|
 Code |
 Article |
 3918 Hits
|
 VB.Net Language
|
Mike Prestwood
|
44. VB.Net Pointers (None)
VB.Net doesn't support pointers. The closest it comes is IntPtr which you use to get pointer handles on windows, files, etc.
C# does have better support for pointers and C++/CLI has extensive support. One solution when it's really needed in VB.Net is to code in C# or C++/CLI and add it to your project.
However, VB.Net does support references.
|
 Code
3604 Hits
|
 VB.Net Language
|
Mike Prestwood
|
45. VB.Net Polymorphism
C# supports the following types of polymorphism:
|
 Code
 3761 Hits
|
 VB.Net Language
|
Mike Prestwood
|
46. VB.Net Prevent Derivation (NotInheritable, NotOverridable)
With VB.Net, use the NotInheritable keyword to prevent a class from being inherited from and use the NotOverridable keyword to prevent a method from being overridden.
A method marked NotOverridable must override an ancestor method. If you mark a class NotInheritable, all members are implicitly not overridable so the NotOverridable keyword is not legal.
55 months ago, and updated 52 months ago
|
 Code
 5154 Hits
|
 VB.Net Language
|
Mike Prestwood
|
47. VB.Net Report Tools Overview
Microsoft includes ReportViewer Starting with Visual Studio 2005. You can even surface this .Net solution in your VB Classic application if you wish. For WebForm applications the client target is the browser (a document interfaced GUI), a common solution is to simply output an HTML formatted page with black text and a white background (not much control but it does work for some situations). For WinForm applications, Crystal Reports is still very popular with VB.Net developers because it has been bundled with Visual Basic since VB 3, it's overall popularity, and compatibility with many different development tools.
54 months ago, and updated 53 months ago
|
 Code
 3358 Hits
|
 VB.Net Language
|
Mike Prestwood
|
48. VB.Net Self Keyword (Me)
To refer to the current instance of a class or structure, use the Me keyword. Me provides a way to refer to the specific instance in which the code is currently executing. It is particularly useful for passing information about the currently executing instance.
The Me keyword is also used as a modifier of the first parameter of an extension method.
You cannot use Me with static method functions because static methods do not belong to an object instance. If you try, you'll get an error.
|
 Code
4752 Hits
|
 VB.Net Language
|
Mike Prestwood
|
49. VB.Net Shared Members (Shared)
VB.Net supports both static members and static classes (use the keyword Shared). You can add a static method, field, property, or event to an existing class.
You can designate a class as static and the compiler will ensure all methods in that class are static. You can add a constructor to a static class to initialize values.
The CLR automatically loads static classes with the program or namespace.
55 months ago, and updated 52 months ago
|
 Code
3441 Hits
|
 VB.Net Language
|
Mike Prestwood
|
50. VB.Net String Concatenation (+ or &)
Most (many?) developers recommend using "+" because that's what C# uses but "&" is also available and many VB Classic and VBA/ASP developers prefer it. My preference is to use the & because it offers implicit type casting.
54 months ago, and updated 52 months ago
|
 Code
 2668 Hits
|
 VB.Net Language
|
Mike Prestwood
|
51. VB.Net Unary Operators
An operation with only one operand (a single input). The following are the�VB.Net unary operators: +, -, isFalse, isTrue, and Not. A unary operator method can return any type but takes only one parameter, which must be the type of the containing class.
54 months ago, and updated 51 months ago
|
 Code
 4216 Hits
|
 VB.Net Language
|
Mike Prestwood
|
52. VB.Net Variables (Dim x As Integer=0)
Variables are case sensitive but VS.Net will auto-fix your variable names to the defined case. You can declare variables in-line wherever you need them and declarative variable assignment is supported.
54 months ago, and updated 52 months ago
|
 Code
3266 Hits
|
 VB.Net Language
|