Cover | Table of Contents
Microsoft.VisualBasic
namespace. It does not attempt to document the core classes of the
.NET Framework Class Library.
Constant WidthMicrosoft.VisualBasic
namespace. It does not attempt to document the core classes of the
.NET Framework Class Library.
Constant WidthPublic Class MainForm Inherits Form
Public Class MainForm : Inherits Form
')
and the Rem keyword. They may appear at any place
within a line.
Option Explicit setting.
(The statement must appear at the top of a code module.) If
Off, VB is a weakly typed language; variables need
not be declared in advance, and all undeclared variables will be cast
as type Object until they are initialized. If
On (its default setting), each variable must be
declared in advance, but its data type need not be specified. If no
type is explicitly declared, variables are cast as type
Object until their first use.
True or False)
value. Corresponds to System.Boolean.
System.Byte.
System.Char.
System.DataTime.
System.Decimal.
System.Double.
System.Int32.
System.Int64.
Object is
VB's "universal"
data type and corresponds to System.Object.
System.Int16.
System.Single.
System.String.
System.SByteSystem.UInt16System.UInt32System.UInt64Option Explicit is
On (its default value). In that case, you can
declare variables using the Dim,
Public, Private,
Protected, Friend, or
Protected Friend statements.
|
Operator
|
Description
|
|---|---|
+ |
Addition, string concatenation
|
+= |
Increment and assign
|
- |
Subtraction, unary operator
|
-= |
Subtract and assign
|
/ |
Division
|
/= |
Divide and assign
|
\ |
Integer division (no remainder)
|
\= |
Integer division and assignment
|
Mod |
Modulo arithmetic
|
* |
Multiplication
|
*= |
Multiply and assign
|
^ |
Exponentiation
|
^= |
Exponentiation and assignment
|
& |
String concatenation
|
&= |
String concatenation and assignment
|
= |
Equality, assignment
|
Is |
Equality (for object references)
|
< |
Less than
|
<=, =< |
Less than or equal to
|
> |
Greater than
|
>=, => |
Greater than or equal to
|
<>, >< |
Not equal to
|
And |
Logical or bitwise conjunction
|
AndAlso |
Logical conjunction with short-circuiting
|
Or |
Logical or bitwise disjunction
|
OrElse |
Logical disjunction with short-circuiting
|
Not |
Logical or bitwise negation
|
Xor |
Logical or bitwise exclusion
|
vbGet |
vbMethod |
vbLet |
vbSet |
vbBinaryCompare |
vbTextCompare |
vbSunday |
vbSaturday |
vbMonday |
vbUseSystem |
vbTuesday |
vbUseSystemDayOfWeek |
vbWednesday |
vbFirstJan1 |
vbThursday |
vbFirstFourDays |
vbFriday |
vbFirstFullWeek |
vbGeneralDate |
vbShortDate |
vbLongDate |
vbShortTime |
vbLongTime |
vbObjectError |
vbArchive |
vbNormal |
vbDirectory |
vbSystem |
vbHidden |
vbVolume |
vbReadOnly |
False |
vbTrue |
True |
vbUseDefault |
vbFalse |
vbAbortRetryIgnore |
vbRetryCancel |
vbMsgBoxHelp |
vbYesNo |
vbOKCancel |
vbYesNoCancel |
vbOKOnly |
vbDefaultButton1 |
vbDefaultButton3 |
vbDefaultButton2 |
vbCritical |
vbInformation |
vbExclamation |
vbQuestion |
vbApplicationModal |
vbSystemModal |
vbAbort |
vbOK |
vbCancel |
vbRetry |
vbIgnore |
vbYes |
vbNo |
vbMsgBoxRight |
vbMsgBoxSetForeground |
vbMsgBoxRtlReading |
vbBack |
vbNewLine |
vbCr |
vbNullChar |
vbCrLf |
vbNullString |
vbFormFeed |
vbTab |
vbLf |
vbVerticalTab |
vbArray |
vbInteger |
vbBoolean |
vbLong |
vbByte |
vbNull |
vbCurrency |
vbObject |
vbDate |
vbSingle |
vbDecimal |
vbString |
vbDouble |
vbUserDefinedType |
vbEmpty |
vbVariant |
vbHide |
vbNarrow |
vbHiragana |
vbNormalFocus |
vbKatakana |
vbNormalNoFocus |
vbLinguisticCasing |
vbProperCase |
vbLowerCase |
vbSimplifiedChinese |
vbMaximizedFocus |
vbTraditionalChinese |
vbMinimizedFocus |
vbUpperCase |
vbMinimizedNoFocus |
vbWide |
Const statement.
Microsoft.VisualBasic namespace also defines a
number of enumerations. Many of their members are functionally
identical to almost identically named constants listed in the
aforementioned Section 1.7.
Hide |
MinimizedNoFocus |
MaximizedFocus |
NormalFocus |
MinimizedFocus |
NormalNoFocus |
Get |
Set |
Method |
Binary |
Text |
ControlChars class.
They can be referenced just as enumerated members; for example:
Addr = "123 West St. & ControlChars.CrLf & _
"Apt. 12C"
Back |
NewLine |
Cr |
NullChar |
CrLf |
Quote |
FormFeed |
Tab |
Lf |
VerticalTab |
GeneralDate |
ShortDate |
LongDate |
ShortTime |
LongTime |
Day |
Quarter |
DayOfYear |
Second |
Hour |
Weekday |
Minute |
WeekOfYear |
Month |
Year |
BegOfPeriod |
EndOfPeriod |
Archive |
ReadOnly |
Directory |
System |
Hidden |
Volume |
Normal |
Friday |
System |
Monday |
Tuesday |
Saturday |
Thursday |
Sunday |
Wednesday |
Microsoft.VisualBasic namespace.
/r switch using the VB command line compiler. When
a type is instantiated or a type member is invoked, ordinarily the
type's fully qualified namespace must be included.
For example, a new instance of an
ApplicationException class is generated by the
following code fragment:
Dim e As New System.ApplicationException( )
Imports directive to import a
type's namespace. The Imports
directive appears at the top of a file, after any
Option statements and before any type or module
definitions. Using Imports, we can instantiate an
ApplicationException object as follows:
Dim e As New ApplicationException( )
Public Class PgmStruct
Private Value As Integer
Public Sub New(x As Integer)
Value = x
End Sub
Public Shared Sub Main( )
Dim obj As New PgmStruct(100)
Console.WriteLine(obj.Value)
End Sub
End Class
Nothing. More than one array can be
specified by using commas to delimit
arraylist.
True or False)False.
Preserve optional; Keywordupper [, upper] ...
Collection#Const directive, and
arithmetic or logical operators except Is
True or
False
True
True or
False.
furtherexpression is only evaluated if the
preceding expression evaluates to False
True
False
#Const directive to assign a value to a
conditional compiler constant.
#If...Then...#End If statement
block.
True are included in the executable. You can use
the #Else statement to execute code when the
#If...Then expression evaluates to
False. You can also use an
#ElseIf statement to evaluate more expressions if
previous expressions in the same block have evaluated to
Nothing,
Fix returns Nothing.
Int(3.14) and
Fix(3.14) return 3. If
number is negative,
Fix removes its fractional part, thereby
returning the next greater whole number. For example,
Fix(-3.667) returns -3. This contrasts with
Int, which returns the negative integer less
than or equal to number (or -4, in the case of our example).
|
number
|
Return value
|
|---|---|
|
Nothing
|
Zero (0)
|
|
Any other number
|
Up to eight hexadecimal characters
|
DateInterval enum
yyyy |
Year
|
q |
Quarter
|
m |
Month
|
y |
Day of year
|
d |
Day
|
w |
Weekday
|
ww |
Week
|
h |
Hour
|
n |
Minute
|
s |
Second
|
DateInterval enum:
Enum DateInterval Day DayOfYear Hour Minute Month Quarter Second Week Weekday WeekOfYear End Enum
DateInterval enumPublic, Private, and
Friend
MustInherit or
NotInheritable, must be used.
MustInherit specifies that objects of this class
cannot be created, but that objects of derived classes can be
created. NotInheritable specifies that this class
cannot be used as a base class
Inherits or Implements
statements appear in a class module, they must appear before any
other statements in the module. Moreover, the
Inherits keyword must appear before the
Implements keyword.
Public, Private,
Protected, Friend, or
Protected Friend. The
Dim keyword is equivalent to
Private when used in class modules (but it is
equivalent to Public in structures). Property
declarations are automatically Public.
Class...End Class construct
can include the following elements:
Public variables are public properties of the
class; Public procedures are public methods of the
class.
Default keyword.
Public,
Private, Protected,
Friend, or Protected
Friend.
System.Exception object or an object inherited
from it containing the current exception