Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (3 votes)
652 views

VB NET Quick Reference

This document provides a summary of variable declarations, procedures, loops, branching, operators, and error handling in VB.NET. It defines various variable types like integers, booleans, strings, and arrays. It also describes procedures, properties, and how to pass parameters by value, reference, and dynamically. Control structures like if/else, select case, while, for, foreach, and do loops are outlined. Finally, it touches on operators, exception handling, and the global assembly cache location.

Uploaded by

crutili
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
652 views

VB NET Quick Reference

This document provides a summary of variable declarations, procedures, loops, branching, operators, and error handling in VB.NET. It defines various variable types like integers, booleans, strings, and arrays. It also describes procedures, properties, and how to pass parameters by value, reference, and dynamically. Control structures like if/else, select case, while, for, foreach, and do loops are outlined. Finally, it touches on operators, exception handling, and the global assembly cache location.

Uploaded by

crutili
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

VB.

NET Quick Reference August 2006 Edition

Variable Declaration Procedures/Properties

Const trialDays As Integer = 30 'Constant //Access Modifiers: public, friend,


Dim isInvoiced As Boolean = True 'Boolean //private, protected, protected friend
Dim keystroke As Char '16 bit Unicode character
Dim count As Integer = 0 'Signed 32-bit integer Private Function Markup(ByVal total _
Dim invoiceId As Long = 0 'Signed 64-bit integer As Double) As Double
Dim total As Double = 0 'Double precision float Return total * _markupPercent
Dim tax As Single = 0 'Single precision float End Function
Dim firstName As String = String.Empty 'String
Friend Property InvoiceId() As Integer
Dim today As DateTime = DateTime.Now 'Current Date Get
Dim saleDate As DateTime = New _ Return _invoiceId
DateTime(2004, 1, 23, 13, 48, 39) End Get
'(year, month, day, hours, minutes, seconds) Set(ByVal Value As Integer)
_invoiceId = Value
Dim items(100) As Integer 'Array (See ArrayList) End Set
End Property
Enum OrderStatus As Integer
NewOrder = 1
Picked
Shipped
End Enum

Loops Branching Operators

'While Loop 'If/Else statement Computational


While i < 10 If (i > 0 AndAlso j <> 5) OrElse k = 1 Then - Negate/Subtract
i += 1 Else If (i < 0) Then * Multiplication
End If / Division Float
End While \ Division Integer
Select Case i 'Case statement mod Modulus
'For Loop + Addition
Case Is < 2
For i As Integer = 0 To 9 Return "Less than two"
If (isFound) Then _ Case 3, 5 Logical
Exit For 'Exit loop Return "Three or five" not Logical NOT
Next Case Else 'Default < Less than
Return "Other" > Greater than
'For each loop End Select <= Less than or equal
Dim dt As DataTable >= Greater than or
For Each _ equal
j= CInt(IIf(i > 0, 1, 0)) 'Immediate If
dr As DataRow In dt.Rows = Equality
<> Inequality
Console.WriteLine( _ And Logical AND
dr(0).ToString()) Error Handling Or Logical OR
Next AndAlso Short Circuit
Try
i = 10 / 0 OrElse Short Circuit
'Do Loop
Do ' "Catch" the error
Assignment
i += 1 Catch ex As Exception
Dim s As String = "Error:" + vbCrLf _ = Assignment
Loop Until i > 9
+ "Target: " + ex.TargetSite.ToString _
Compound assignment
+ vbCrLf + "Error: " _
operators
Parameter Definitions + ex.Message.ToString + vbCrLf _
+ "Trace: " + ex.StackTrace.ToString += Addition
'Value,Reference,Dynamic MsgBox(s, MsgBoxStyle.Critical, _ -= Subtraction
Private Sub Calc( _ "Error") *= Multiplication
ByVal i As Integer, _ /= Division
Finally 'Always do this
ByRef j As Integer, _ inputFile.Close()
ByVal ar() As Integer) End Try GAC Location
End Sub
C:\WINDOWS\assembly\GAC

Free Version. For more Quick Reference sheets go to www.KellermanSoftware.com

You might also like