"Vb.net Quick Reference Cheat Sheet"

ADVERTISEMENT
ADVERTISEMENT

Download "Vb.net Quick Reference Cheat Sheet"

Download PDF

Fill PDF online

Rate (4.6 / 5) 7 votes
VB.NET Quick Reference
August 2006 Edition
Variable Declaration
Procedures/Properties
//Access Modifiers: public, friend,
Const
trialDays
As Integer
= 30
'Constant
//private, protected, protected friend
Dim
isInvoiced
As Boolean
=
True
'Boolean
Dim
keystroke
As Char
'16 bit Unicode character
Private Function Markup(ByVal
total _
Dim
count
As Integer
= 0
'Signed 32-bit integer
As
Double)
As Double
Dim
invoiceId
As Long
= 0
'Signed 64-bit integer
Return
total * _markupPercent
Dim
total
As Double
= 0
'Double precision float
End Function
Dim
tax
As Single
= 0
'Single precision float
Dim
firstName
As String
= String.Empty
'String
Friend Property
InvoiceId()
As Integer
Get
Dim
today
As
DateTime = DateTime.Now
'Current Date
Return
_invoiceId
Dim
saleDate
As
DateTime =
New
_
End Get
DateTime(2004, 1, 23, 13, 48, 39)
Set(ByVal
Value
As
Integer)
'(year, month, day, hours, minutes, seconds)
_invoiceId = Value
End Set
Dim
items(100)
As Integer
'Array (See ArrayList)
End Property
Enum
OrderStatus
As Integer
NewOrder = 1
Picked
Shipped
End Enum
Loops
Branching
Operators
Computational
'If/Else statement
'While Loop
-
Negate/Subtract
If
(i > 0
AndAlso
j <> 5)
OrElse
k = 1
Then
While
i < 10
*
Multiplication
Else If
(i < 0)
Then
i += 1
/
Division Float
End If
End While
\
Division Integer
mod Modulus
Select Case
i
'Case statement
'For Loop
+
Addition
Case Is
< 2
For
i
As Integer
= 0
To
9
Return
"Less than two"
If
(isFound)
Then
_
Logical
Case
3, 5
Exit For
'Exit loop
not Logical NOT
Return
"Three or five"
Next
<
Less than
Case Else
'Default
>
Greater than
Return
"Other"
'For each loop
<=
Less than or equal
End Select
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
Error Handling
dr(0).ToString())
Or
Logical OR
Next
AndAlso Short Circuit
Try
OrElse
Short Circuit
i = 10 / 0
'Do Loop
' "Catch" the error
Do
Assignment
Catch
ex
As
Exception
i += 1
=
Assignment
Dim
s
As String
= "Error:" + vbCrLf _
Loop Until
i > 9
+ "Target: " + ex.TargetSite.ToString _
Compound assignment
+ vbCrLf + "Error: " _
operators
Parameter Definitions
+ ex.Message.ToString + vbCrLf _
+= Addition
+ "Trace: " + ex.StackTrace.ToString
-= Subtraction
'Value,Reference,Dynamic
MsgBox(s, MsgBoxStyle.Critical, _
*= Multiplication
Private Sub
Calc( _
"Error")
/= Division
ByVal
i
As
Integer, _
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
VB.NET Quick Reference
August 2006 Edition
Variable Declaration
Procedures/Properties
//Access Modifiers: public, friend,
Const
trialDays
As Integer
= 30
'Constant
//private, protected, protected friend
Dim
isInvoiced
As Boolean
=
True
'Boolean
Dim
keystroke
As Char
'16 bit Unicode character
Private Function Markup(ByVal
total _
Dim
count
As Integer
= 0
'Signed 32-bit integer
As
Double)
As Double
Dim
invoiceId
As Long
= 0
'Signed 64-bit integer
Return
total * _markupPercent
Dim
total
As Double
= 0
'Double precision float
End Function
Dim
tax
As Single
= 0
'Single precision float
Dim
firstName
As String
= String.Empty
'String
Friend Property
InvoiceId()
As Integer
Get
Dim
today
As
DateTime = DateTime.Now
'Current Date
Return
_invoiceId
Dim
saleDate
As
DateTime =
New
_
End Get
DateTime(2004, 1, 23, 13, 48, 39)
Set(ByVal
Value
As
Integer)
'(year, month, day, hours, minutes, seconds)
_invoiceId = Value
End Set
Dim
items(100)
As Integer
'Array (See ArrayList)
End Property
Enum
OrderStatus
As Integer
NewOrder = 1
Picked
Shipped
End Enum
Loops
Branching
Operators
Computational
'If/Else statement
'While Loop
-
Negate/Subtract
If
(i > 0
AndAlso
j <> 5)
OrElse
k = 1
Then
While
i < 10
*
Multiplication
Else If
(i < 0)
Then
i += 1
/
Division Float
End If
End While
\
Division Integer
mod Modulus
Select Case
i
'Case statement
'For Loop
+
Addition
Case Is
< 2
For
i
As Integer
= 0
To
9
Return
"Less than two"
If
(isFound)
Then
_
Logical
Case
3, 5
Exit For
'Exit loop
not Logical NOT
Return
"Three or five"
Next
<
Less than
Case Else
'Default
>
Greater than
Return
"Other"
'For each loop
<=
Less than or equal
End Select
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
Error Handling
dr(0).ToString())
Or
Logical OR
Next
AndAlso Short Circuit
Try
OrElse
Short Circuit
i = 10 / 0
'Do Loop
' "Catch" the error
Do
Assignment
Catch
ex
As
Exception
i += 1
=
Assignment
Dim
s
As String
= "Error:" + vbCrLf _
Loop Until
i > 9
+ "Target: " + ex.TargetSite.ToString _
Compound assignment
+ vbCrLf + "Error: " _
operators
Parameter Definitions
+ ex.Message.ToString + vbCrLf _
+= Addition
+ "Trace: " + ex.StackTrace.ToString
-= Subtraction
'Value,Reference,Dynamic
MsgBox(s, MsgBoxStyle.Critical, _
*= Multiplication
Private Sub
Calc( _
"Error")
/= Division
ByVal
i
As
Integer, _
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