Microsoft Visual Basic .NET Language Reference  

Overview

Here’s official documentation for the Visual Basic .NET language, including descriptions of all language elements from A to Z. This LANGUAGE REFERENCE is taken from the electronic product documentation for Visual Basic .NET. In its printed form, this material is portable, ...

See more details below
Available through our Marketplace sellers.
Other sellers (Paperback)
  • All (30) from $1.99   
  • New (1) from $20.95   
  • Used (29) from $1.99   
Close
Sort by
Page 1 of 1
Showing All
Note: Marketplace items are not eligible for any BN.com coupons and promotions
$20.95
Seller since 2008

Feedback rating:

(169)

Condition:

New — never opened or used in original packaging.

Like New — packaging may have been opened. A "Like New" item is suitable to give as a gift.

Very Good — may have minor signs of wear on packaging but item works perfectly and has no damage.

Good — item is in good condition but packaging may have signs of shelf wear/aging or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Acceptable — item is in working order but may show signs of wear such as scratches or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Used — An item that has been opened and may show signs of wear. All specific defects should be noted in the Comments section associated with each item.

Refurbished — A used item that has been renewed or updated and verified to be in proper working condition. Not necessarily completed by the original manufacturer.

New
0735615527 BRAND NEW NEVER USED IN STOCK 125,000+ HAPPY CUSTOMERS SHIP EVERY DAY WITH FREE TRACKING NUMBER

Ships from: fallbrook, CA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
Page 1 of 1
Showing All
Close
Sort by
Sending request ...

Overview

Here’s official documentation for the Visual Basic .NET language, including descriptions of all language elements from A to Z. This LANGUAGE REFERENCE is taken from the electronic product documentation for Visual Basic .NET. In its printed form, this material is portable, easy to use, and easy to browse—a comprehensive alternative to the substantial online help system in Visual Basic .NET Standard software.
Get the details you need on language and run-time elements, including:

  • Attributes
  • Constants and enumerations
  • Data types
  • Directives
  • Functions
  • Keywords
  • Methods
  • Objects
  • Operators
  • Properties
  • Statements
Read More Show Less

Editorial Reviews

From Barnes & Noble
The Barnes & Noble Review
Forgive us for saying so, but sometimes books are just plain easier than online docs. Lots of times, in fact. That's why, if you're a Visual Basic .NET developer, you'll appreciate having Microsoft Visual Basic .NET Language Reference. This is the official printed version of Microsoft's Visual Basic .NET electronic product documentation -- made portable, tangible, and readable in places your computer won't go.

The book starts with a systematic review of what's changed in Visual Basic. As you've probably heard or seen, many old VB elements have been renamed, reclassified, combined, or moved into the Common Language Runtime. Math functions? Look in System Namespace, Math Class. Date statement? Look in VB Run-Time Library Members, DateAndTime module. "Empty" keyword? Gone. (There's something vaguely Zen-like about that change.)

The heart of the book is a cleanly formatted A-to-Z reference to the entire language and runtime: attributes, constants, enumerations, data types, directives, functions, keywords, methods, objects, operators, properties, and statements. Nearly every element is illuminated with at least one example.

How many times will you need to reach for an answer as you work with VB .NET? Run Visual Studio .NET full screen -- and get your answers right here. (Bill Camarda)

Bill Camarda is a consultant, writer, and web/multimedia content developer with nearly 20 years' experience in helping technology companies deploy and market advanced software, computing, and networking products and services. He served for nearly ten years as vice president of a New Jersey–based marketing company, where he supervised a wide range of graphics and web design projects. His 15 books include Special Edition Using Word 2000 and Upgrading & Fixing Networks For Dummies®, Second Edition.

Read More Show Less

Product Details

  • ISBN-13: 9780735615526
  • Publisher: Microsoft Press
  • Publication date: 3/28/2002
  • Pages: 522
  • Product dimensions: 7.48 (w) x 9.30 (h) x 1.12 (d)

Meet the Author

Founded in 1975, Microsoft is the worldwide leader in software, services, and solutions that help people and businesses realize their full potential. Since 1988, Microsoft has been building accessibility options right into its products to enable everyone to personalize their PCs to make them easier and more comfortable to see, hear, and use.

Read More Show Less

Table of Contents

Before You Begin;
Typographic and Code Conventions;
Chapter 1: Introduction to Visual Basic .NET;
1.1 Language Changes in Visual Basic;
1.2 Overview of Visual Basic Concepts;
1.3 Visual Basic Language Keywords;
Chapter 2: A–Z Reference;
2.1 #Const Directive;
2.2 #ExternalSource Directive;
2.3 #If...Then...#Else Directives;
2.4 #Region Directive;
2.5 & Operator;
2.6 &= Operator;
2.7
• Operator;
2.8 *= Operator;
2.9 + Operator;
2.10 += Operator;
2.11 - Operator;
2.12 -= Operator;
2.13 / Operator;
2.14 /= Operator;
2.15 = Operator;
2.16 \ Operator;
2.17 \= Operator;
2.18 ^ Operator;
2.19 ^= Operator;
2.20 Add Method;
2.21 AddHandler Statement;
2.22 AddressOf Operator;
2.23 Alias;
2.24 And Operator;
2.25 AndAlso Operator;
2.26 Ansi;
2.27 AppActivate Function;
2.28 AppWinStyle Enumeration;
2.29 As;
2.30 Asc, AscW Functions;
2.31 Assembly;
2.32 Auto;
2.33 Beep Function;
2.34 Boolean Data Type;
2.35 ByRef;
2.36 Byte Data Type;
2.37 ByVal;
2.38 Call Statement;
2.39 CallByName Function;
2.40 CallType Enumeration;
2.41 Case;
2.42 Char Data Type;
2.43 ChDir Function;
2.44 ChDrive Function;
2.45 Choose Function;
2.46 Chr, ChrW Functions;
2.47 Class Statement;
2.48 Clear Method;
2.49 Collection Object;
2.50 ComClassAttribute Class;
2.51 ComClassAttribute Constructor;
2.52 ComClassAttribute.ClassID Property;
2.53 ComClassAttribute.EventID Property;
2.54 ComClassAttribute.InterfaceID Property;
2.55 ComClassAttribute.InterfaceShadows Property;
2.56 Command Function;
2.57 CompareMethod Enumeration;
2.58 Const Statement;
2.59 Count Property;
2.60 CreateObject Function;
2.61 CType Function;
2.62 CurDir Function;
2.63 Date Data Type;
2.64 DateAdd Function;
2.65 DateDiff Function;
2.66 DateFormat Enumeration;
2.67 DateInterval Enumeration;
2.68 DatePart Function;
2.69 DateSerial Function;
2.70 DateString Property;
2.71 DateValue Function;
2.72 Day Function;
2.73 DDB Function;
2.74 Decimal Data Type;
2.75 Declare Statement;
2.76 Default;
2.77 Delegate Statement;
2.78 DeleteSetting Function;
2.79 Derived Math Functions;
2.80 Description Property;
2.81 Different Formats for Different Numeric Values (Format Function);
2.82 Dim Statement;
2.83 Dir Function;
2.84 DirectCast;
2.85 Do...Loop Statements;
2.86 Double Data Type;
2.87 DueDate Enumeration;
2.88 Each;
2.89 Else;
2.90 ElseIf;
2.91 End;
2.92 End Statement;
2.93 Enum Statement;
2.94 Environ Function;
2.95 EOF Function;
2.96 Erase Statement;
2.97 Erl Property;
2.98 Err Object;
2.99 Error;
2.100 Error Statement;
2.101 ErrorToString Function;
2.102 Event Statement;
2.103 Exit Statement;
2.104 Explicit;
2.105 False;
2.106 FileAttr Function;
2.107 FileAttribute Enumeration;
2.108 FileClose Function;
2.109 FileCopy Function;
2.110 FileDateTime Function;
2.111 FileGet Function;
2.112 FileGetObject Function;
2.113 FileLen Function;
2.114 FileOpen Function;
2.115 FilePut Function;
2.116 FilePutObject Function;
2.117 FileWidth Function;
2.118 Filter Function;
2.119 FirstDayOfWeek Enumeration;
2.120 FirstWeekOfYear Enumeration;
2.121 For;
2.122 For Each...Next Statements;
2.123 For...Next Statements;
2.124 Format Function;
2.125 FormatCurrency Function;
2.126 FormatDateTime Function;
2.127 FormatNumber Function;
2.128 FormatPercent Function;
2.129 FreeFile Function;
2.130 Friend;
2.131 Function Statement;
2.132 FV Function;
2.133 Get Statement;
2.134 GetAllSettings Function;
2.135 GetAttr Function;
2.136 GetChar Function;
2.137 GetEnumerator Method;
2.138 GetException Function;
2.139 GetObject Function;
2.140 GetSetting Function;
2.141 GetType Operator;
2.142 GoTo Statement;
2.143 Handles;
2.144 HelpContext Property;
2.145 HelpFile Property;
2.146 Hex Function;
2.147 Hour Function;
2.148 If...Then...Else Statements;
2.149 IIf Function;
2.150 Implements;
2.151 Implements Statement;
2.152 Imports Statement;
2.153 In;
2.154 Inherits Statement;
2.155 Input Function;
2.156 InputBox Function;
2.157 InputString Function;
2.158 InStr Function;
2.159 InStrRev Function;
2.160 Int, Fix Functions;
2.161 Integer Data Type;
2.162 Interface Statement;
2.163 IPmt Function;
2.164 IRR Function;
2.165 Is;
2.166 Is Operator;
2.167 IsArray Function;
2.168 IsDate Function;
2.169 IsDBNull Function;
2.170 IsError Function;
2.171 IsNothing Function;
2.172 IsNumeric Function;
2.173 IsReference Function;
2.174 Item Property;
2.175 Join Function;
2.176 Kill Function;
2.177 LastDLLError Property;
2.178 LBound Function;
2.179 LCase Function;
2.180 Left Function;
2.181 Len Function;
2.182 Lib;
2.183 Like Operator;
2.184 LineInput Function;
2.185 Loc Function;
2.186 Lock, Unlock Functions;
2.187 LOF Function;
2.188 Long Data Type;
2.189 Loop;
2.190 LSet Function;
2.191 LTrim, RTrim, and Trim Functions;
2.192 Math Functions;
2.193 Me;
2.194 Mid Function;
2.195 Mid Statement;
2.196 Minute Function;
2.197 MIRR Function;
2.198 MkDir Function;
2.199 Mod Operator;
2.200 Module;
2.201 Module Statement;
2.202 Month Function;
2.203 MonthName Function;
2.204 MsgBox Function;
2.205 MsgBoxResult Enumeration;
2.206 MsgBoxStyle Enumeration;
2.207 MustInherit;
2.208 MustOverride;
2.209 MyBase;
2.210 MyClass;
2.211 Namespace Statement;
2.212 New;
2.213 Next;
2.214 Not Operator;
2.215 Nothing;
2.216 NotInheritable;
2.217 NotOverridable;
2.218 Now Property;
2.219 NPer Function;
2.220 NPV Function;
2.221 Number Property;
2.222 Object Data Type;
2.223 Objects;
2.224 Oct Function;
2.225 Off;
2.226 On;
2.227 On Error Statement;
2.228 OpenAccess Enumeration;
2.229 OpenMode Enumeration;
2.230 OpenShare Enumeration;
2.231 Operators Summary;
2.232 Option;
2.233 Option Compare Statement;
2.234 Option Explicit Statement;
2.235 Option Strict Statement;
2.236 Optional;
2.237 Or Operator;
2.238 OrElse Operator;
2.239 Overloads;
2.240 Overridable;
2.241 Overrides;
2.242 ParamArray;
2.243 Partition Function;
2.244 Pmt Function;
2.245 PPmt Function;
2.246 Predefined Date/Time Formats (Format Function);
2.247 Predefined Numeric Formats (Format Function);
2.248 Preserve;
2.249 Print and Display Constants;
2.250 Print, PrintLine Functions;
2.251 Private;
2.252 Property Statement;
2.253 Protected;
2.254 Public;
2.255 PV Function;
2.256 QBColor Function;
2.257 Raise Method;
2.258 RaiseEvent Statement;
2.259 Randomize Statement;
2.260 Rate Function;
2.261 ReadOnly;
2.262 ReDim Statement;
2.263 REM Statement;
2.264 Remove Method;
2.265 RemoveHandler Statement;
2.266 Rename Function;
2.267 Replace Function;
2.268 Reset Function;
2.269 Resume;
2.270 Resume Statement;
2.271 Return Statement;
2.272 Returns for CStr;
2.273 RGB Function;
2.274 Right Function;
2.275 RmDir Function;
2.276 Rnd Function;
2.277 RSet Function;
2.278 SaveSetting Function;
2.279 ScriptEngine Property;
2.280 ScriptEngineBuildVersion Property;
2.281 ScriptEngineMajorVersion Property;
2.282 ScriptEngineMinorVersion Property;
2.283 Second Function;
2.284 Seek Function;
2.285 Select...Case Statements;
2.286 Set Statement;
2.287 SetAttr Function;
2.288 Shadows;
2.289 Shared;
2.290 Shell Function;
2.291 Short Data Type;
2.292 Single Data Type;
2.293 SLN Function;
2.294 Source Property;
2.295 Space Function;
2.296 SPC Function;
2.297 Split Function;
2.298 Static;
2.299 Step;
2.300 Stop Statement;
2.301 Str Function;
2.302 StrComp Function;
2.303 StrConv Function;
2.304 StrDup Function;
2.305 String Data Type;
2.306 StrReverse Function;
2.307 Structure Statement;
2.308 Sub Statement;
2.309 Switch Function;
2.310 SYD Function;
2.311 SyncLock Statement;
2.312 SystemTypeName Function;
2.313 TAB Function;
2.314 Then;
2.315 Throw Statement;
2.316 TimeOfDay Property;
2.317 Timer Property;
2.318 TimeSerial Function;
2.319 TimeString Property;
2.320 TimeValue Function;
2.321 To;
2.322 Today Property;
2.323 Tristate Enumeration;
2.324 True;
2.325 Try...Catch...Finally Statements;
2.326 Type Conversion Functions;
2.327 TypeName Function;
2.328 TypeOf;
2.329 UBound Function;
2.330 UCase Function;
2.331 Unicode;
2.332 Until;
2.333 User-Defined Data Type;
2.334 User-Defined Date/Time Formats (Format Function);
2.335 User-Defined Numeric Formats (Format Function);
2.336 Val Function;
2.337 VariantType Enumeration;
2.338 VarType Function;
2.339 VBFixedArrayAttribute Class;
2.340 VBFixedArrayAttribute Constructor;
2.341 VBFixedArrayAttribute.FirstBound Field;
2.342 VBFixedArrayAttribute.SecondBound Field;
2.343 VBFixedStringAttribute Class;
2.344 VBFixedStringAttribute Constructor;
2.345 VBFixedStringAttribute.SizeConst Field;
2.346 VbStrConv Enumeration;
2.347 VbTypeName Function;
2.348 Weekday Function;
2.349 WeekdayName Function;
2.350 When;
2.351 While;
2.352 While...End While Statements;
2.353 With...End With Statements;
2.354 WithEvents;
2.355 Write, WriteLine Functions;
2.356 WriteOnly;
2.357 Xor Operator;
2.358 Year Function;
Operators;
Operators Listed by Functionality;
Operator Precedence in Visual Basic;
Arithmetic Operators;
Assignment Operators;
Comparison Operators;
Concatenation Operators;
Logical/Bitwise Operators;
Miscellaneous Operators;
Summary Lists;
#Compiler Directive Summary;
Arrays Summary;
Collection Object Summary;
Control Flow Summary;
Conversion Summary;
Data Type Summary;
Data Types Summary;
Dates and Times Summary;
Declarations and Constants Summary;
Directories and Files Summary;
Errors Summary;
Financial Summary;
Information and Interaction Summary;
Input and Output Summary;
Math Summary;
Registry Summary;
String Manipulation Summary;
Member Lists;
Visual Basic Run-Time Library Members;
Err Object Members;
Collection Object Members;
ComClassAttribute Class Members;
VBFixedArrayAttribute Class Members;
VBFixedStringAttribute Class Members;
Keywords and Members by Task;
Conversion Functions;
See Also;
Visual Basic Compiler Options;
Visual Basic Compiler Options Listed Alphabetically;
Visual Basic Compiler Options Listed by Category;
@ (Specify Response File);
/addmodule;
/baseaddress;
/bugreport;
/debug;
/define;
/delaysign;
/help, /?;
/imports;
/keycontainer;
/keyfile;
/libpath;
/linkresource;
/main;
/nologo;
/nowarn;
/optimize;
/optioncompare;
/optionexplicit;
/optionstrict;
/out;
/quiet;
/recurse;
/reference;
/removeintchecks;
/resource;
/rootnamespace;
/target;
/utf8output;
/verbose;
/warnaserror;
/win32icon;
/win32resource;
Work Light;
Read More Show Less

First Chapter

A–Z Reference
  • #Const Directive
  • #ExternalSource Directive
  • #If...Then...#Else Directives
  • #Region Directive
  • & Operator
  • &= Operator
  • * Operator
  • *= Operator
  • + Operator
  • += Operator
  • - Operator
  • -= Operator
  • / Operator
  • /= Operator
  • = Operator
  • \ Operator
  • \= Operator
  • ^ Operator
  • ^= Operator
  • Add Method
  • AddHandler Statement
  • AddressOf Operator
  • Alias
  • And Operator
  • AndAlso Operator
  • Ansi
  • AppActivate Function
  • AppWinStyle Enumeration
  • As
  • Asc, AscW Functions
  • Assembly
  • Auto
  • Beep Function
  • Boolean Data Type
  • ByRef
  • Byte Data Type
  • ByVal

A–Z Reference

#Const Directive

Defines conditional compiler constants for Visual Basic.


#Const 
constname 
= 
expression

Parts

constname

Required. String. Name of the constant being defined.

expression

Required. Literal, other conditional compiler constant, or any combination that includes any or all arithmetic or logical operators except Is.

Remarks

Conditional compiler constants are always private to the file in which they appear. You cannot create public compiler constants using the #Const directive; you can create them only in the user interface.

You can use only conditional compiler constants and literals in expression. Using a standard constant defined with #Const causes an error. Conversely, you can use constants defined with the #Const keyword only for conditional compilation. Constants also can be undefined, in which case they have a value of Nothing.

Example

This example uses the #Const directive.


#Const MyCountry = "USA"
#Const Version = "8.0.0012"
#Const CustomerNumber = 36

See Also

#If...Then...#Else Directives, Const Statement

#ExternalSource Directive

Indicates a mapping between source lines and text external to the source, such as an .aspx file.


# ExternalSource( 
StringLiteral , 
IntLiteral 
)
[ LogicalLine+ ]
# End ExternalSource

Parts

StringLiteral

The path to the external source.

IntLiteral

The line number of the first line of the external source.

Logical Line

The line where the error occurs in the external source.

# End ExternalSource

Terminates the #ExternalSource block.

Remarks

A source file may include external source directives that indicate a mapping between source lines and text external to the source, so if errors are encountered during compilation, they are identified as coming from the external source. External source directives have no effect on compilation and may not be nested. They are intended for internal use by the application only.

#If...Then...#Else Directives

Conditionally compiles selected blocks of Visual Basic code.


#If 
expression 
Then
statements
[ #ElseIf expression Then
[ statements ]
...

#ElseIf 
expression 
Then
[ statements ] ]
[ #Else
[ statements ] ]
#End If

Parts

expression

Required for If and ElseIf statements, optional elsewhere. Any expression, consisting exclusively of one or more conditional compiler constants, literals, and operators, that evaluates to True or False. Three conditional compilation constants are provided: Config, Debug, and Trace. Debug and Trace are Boolean datatypes and can be set in the Project Properties dialogue. When Debug is defined, Debug class methods generate output to the Output window. When it is not defined, Debug class methods are not compiled and no Debug output is generated. Similarly, when Trace is defined, Trace class methods generate output to the Output window. When it is not defined, Trace class methods are not compiled and no Trace output is generated. Config is a string datatype, which corresponds to the current setting in the Configuration Manager.

statements

Required for If statement block, optional elsewhere. Visual Basic program lines or compiler directives that are compiled if the associated expression evaluates to True.

#End If

Terminates the #If statement block.

Remarks

On the surface, the behavior of the #If...Then...#Else directives appears the same as that of the If...Then...Else statements. However, the #If…Then…#Else directives evaluate what is compiled by the compiler, whereas the If…Then…Else statements evaluate conditions at run time.

Conditional compilation is typically used to compile the same program for different platforms. It is also used to prevent debugging code from appearing in an executable file. Code excluded during conditional compilation is completely omitted from the final executable file, so it has no effect on size or performance.

Regardless of the outcome of any evaluation, all expressions are evaluated using Option Compare Text. The Option Compare statement does not affect expressions in #If and #ElseIf statements.


NOTE:
No single-line form of the #If, #Else, #ElseIf, and #End If directives exists; that is, no other code can appear on the same line as any of the directives.

Example

This example uses the #If...Then...#Else construct to determine whether to compile certain statements.

#Const CustomerNumber = 36
#If CustomerNumber = 35 Then
' Insert code to be compiled for customer # 35.
#ElseIf CustomerNumber = 36 Then
' Insert code to be compiled for customer # 36.
#Else
' Insert code to be compiled for all other customers.
#End If

See Also

#Const Directive

#Region Directive

Collapses and hides sections of code in Visual Basic .NET files.


#Region 
"
identifier_string
"
#End Region

Parts

identifier_string

Required. String that acts as the title of a region when it is collapsed. Regions are collapsed by default.

#End Region

Terminates the #Region block.

Remarks

The #Region directive lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio® Code Editor. #Region statements support block semantics (such as #If...#End If), meaning that the start and end must be in the same code block.

Example

This example uses the #Region directive.


#Region "MathFunctions"
' Insert code for the Math functions here.
#End Region

& Operator

Generates a string concatenation of two expressions.


result 
= 
expression1 
& 
expression2

Parts

result

Required. Any String or Object variable.

expression1

Required. Any expression.

expression2

Required. Any expression.

Remarks

If the data type of expression1 or expression2 is not String, it is converted to String. The data type of result is String. If one or both expressions are stated as Nothing or have a value of DBNull.value, they are treated as a string with a value of " ".

Example

This example uses the & operator to force string concatenation. The result is a string value representing the concatenation of the two string operands.

Dim myStr As String
myStr = "Hello" & " World" ' Returns "Hello World".

The following example uses the & operator to force string concatentaion on the result of a database lookup. The result is the string value from the database or an empty string in the case of a null value.

Dim rs As Recordset = Cmd.Execute("Select * from …")
Dim myStr As String
myStr=rs("au_id") & ""

See Also

&= Operator, Concatenation Operators, Operator Precedence in Visual Basic, Operators Listed by Functionality

&= Operator

Concatenates a String expression to a String variable and assigns the result to the variable.


variable 
&= 
expression

Parts

variable

Required. Any String variable.

expression

Required. Any String expression.

Example

The following example uses the &= operator to concatenate two String variables and assign the result to the first variable.

Dim var1 As String = "Hello "
Dim var2 As String = "World!"
var1 &= var2 ' The value of var1 is now "Hello World!"

See Also

& Operator, *= Operator, += Operator, -= Operator, /= Operator, = Operator, \= Operator, ^= Operator

* Operator

Multiplies two numbers.


number1 
* 
number2

Parts

number1

Required. Any numeric expression.

number2

Required. Any numeric expression.

Result

The result is the product of number1 and number2.

Supported Types

Byte, Short, Integer, Long, Single, Double, Decimal

Remarks

The data type of the result is the same as that of the data type with the greatest range. The order of range, from least to greatest range, is Byte, Short, Integer, Long, Single, Double, and Decimal.

If an expression is stated as Nothing, or is Empty, it is treated as zero.

Example

This example uses the * operator to multiply two numbers. The result is the product of the two operands.

Dim myValue As Double
myValue = 2 * 2 ' Returns 4.
myValue = 459.35 * 334.90 ' Returns 153836.315.

See Also

*= Operator, Arithmetic Operators, Operator Precedence in Visual Basic, Operators Listed by Functionality

*= Operator

Multiplies the value of a variable by the value of an expression and assigns the result to the variable.


variable 
*= 
expression

Parts

variable

Required. Any numeric variable.

expression

Required. Any numeric expression.

Example

The following example uses the *= operator to multiply one Integer variable by a second and assign the result to the first variable.

Dim var1 As Integer = 10
Dim var2 As Integer = 3
var1 *= var2 ' The value of var1 is now 30.

See Also

&= Operator, * Operator, += Operator, -= Operator, /= Operator, = Operator, \= Operator, ^= Operator

+ Operator

Adds two numbers. Also used to concatenate two strings.


expression1 
+ 
expression2

Parts

expression1

Required. Any numeric expression or string.

expression2

Required. Any numeric expression or string.

Result

The value of the result will be the sum of expression1 and expression2 if expression1 and expression2 are numeric or the result of the concatenation of expression1 and expression2 if expression1 and expression2 are strings.

Supported Types

Byte, Short, Integer, Long, Single, Double, Decimal, String

Remarks

When you use the + operator, you may not be able to determine whether addition or string concatenation will occur. Use the & operator for concatenation to eliminate ambiguity and provide self-documenting code.

If neither expression is an Object, the following rules apply:

If Then
Both expressions are the same numeric data types (Byte, Short, Integer, Long, Single, Double, or Decimal) Add.
Both expressions are strings Concatenate.
One expression is a numeric data type and the other is a string If Option Strict is On, a compile error is generated; if Option Strict is Off, implicitly convert String to Double and add. If String cannot be converted to a numeric value, an InvalidCastException is thrown.
One expression is a numeric data type, and the other is Nothing If Option Strict is On a compile error is generated; if Option Strict is Off, add, with Nothing valued at zero.
One expression is a string, and the other is Nothing If Option Strict is On a compile error is generated; if Option Strict is Off, concatenation, with Nothing = " ".

If one expression is an Object expression, the following rules apply.

If Then
One expression is a numeric Object expression and the other is a numeric value type If Option Strict is On, a compiler error is generated; if Option Strict is Off, add.
One expression is a numeric Object expression and the other is a String type If Option Strict is On, a compiler error is generated; if Option Strict is Off, implicitly convert String to Double and add. If String cannot be converted to a numeric value, an InvalidCastException is thrown.
One expression is a string Object expression and the other is a String type If Option Strict is On, a compiler error is generated; if Option Strict is Off, implicitly convert Object to String, and then concatenate.
One expression is a string Object expression and the other is a numeric value type If Option Strict is On, a compiler error is generated; if Option Strict is Off, implicitly convert Object to Double and add. If Object cannot be converted to a numeric value, an InvalidCastException is thrown.

If both expressions are Object expressions, the following rules apply (Option Strict Off only):

If Then
Both Object expressions are numeric Add.
Both Object expressions are strings Concatenate.
One Object expression is numeric and the other is a string Implicitly cast the numeric Object to Double and add. If Object cannot be converted to a numeric value, an InvalidCastException is thrown.

If one or both expressions are stated as Nothing or have a value of DBNull, they are treated as a string with a value of " ".

Example

This example uses the + operator to add numbers. You can also use the + operator to concatenate strings. However, to eliminate ambiguity, you should use the & operator instead. If the components of an expression created with the + operator are numeric, the arithmetic result is assigned. If the components are exclusively strings, the strings are concatenated. The expression cannot contain components of mixed types. The arithmetic result returns the sum of the two operands. The concatenation result returns a string representing the concatenation of the two operands.

Dim myNumber As Integer
Dim var1 As String
Dim var2 As Integer
myNumber = 2 + 2 ' Returns 4.
myNumber = 4257.04 + 98112 ' Returns 102369.04.
Option Strict On
' Initialize mixed variables.
var1 = "34"
var2 = 6
myNumber = var1 + var2 ' Generates a compile-time error.

Option Strict Off
Var1 = "34"
Var2 = 6
myNumber = var1 + var2
' Returns 40 (addition) after the string in var1 is
' converted to a numeric value. Use of Option Strict Off
' for these operations is not recommended.

See Also

& Operator, Concatenation Operators, Arithmetic Operators, Operators Listed by Functionality, Operator Precedence in Visual Basic

+= Operator

Adds the value of an expression to the value of a variable and assigns the result to the variable. Also concatenates a String expression to a String variable and assigns the result to the variable.


variable 
+= 
expression

Parts

variable

Required. Any numeric or String variable.

expression

Required. Any numeric or String expression.

Remarks

This statement will implicitly perform widening but not narrowing conversions if the compilation environment is enforcing strict semantics. If permissive semantics are allowed, the operator will implicitly perform a variety of string and numeric conversions. These conversions are identical to the conversions described for the + operator. For details on how these conversions are performed, see "+ Operator." For more information on strict and permissive semantics, see "Option Strict Statement."

Example

These examples use the += operator to combine the value of one variable with another. In the first example, += is used with numeric variables to add one value to another. In the second example, += is used with String variables to concatenate one value with another. In both cases, the result is assigned to the first variable.

Dim var1 As Integer = 10
Dim var2 As Integer = 3
var1 += var2 ' The value of var1 is now 13.
' This example uses string variables.
Dim var1 As String = "10"
Dim var2 As String = "3"
var1 += var2 ' The value of var1 is now "103".

See Also

+ Operator, Arithmetic Operators, Concatenation Operators, Operator Precedence in Visual Basic, Operators Listed by Functionality

- Operator

Yields the difference between two numbers or indicates the negative value of a numeric expression.

Syntax 1


expression1 
- 
expression2

Syntax 2


-
number

Parts

number

Required. Any numeric expression.

number1

Required. Any numeric expression.

number2

Required. Any numeric expression.

Result

The result will be the difference between number1 and number2.

Supported Types

Byte, Short, Integer, Long, Single, Double, Decimal

Remarks

In Syntax 1, the - operator is the arithmetic subtraction operator for the difference between two numbers. In Syntax 2, the - operator is the unary negation operator for the negative value of an expression. The data type of the result is the same as that of the data type with the greatest range. The order of range, from least to greatest range, is Byte, Short, Integer, Long, Single, Double, and Decimal.

If an expression is stated as Nothing, it is treated as zero.

Example

This example uses the - operator to calculate and return the difference between two numbers.

Dim myResult As Double
myResult = 4 - 2 ' Returns 2.
myResult = 459.35 - 334.90 ' Returns 124.45.

See Also

-= Operator, Arithmetic Operators, Operator Precedence in Visual Basic, Operators Listed by Functionality

-= Operator

Subtracts the value of an expression from the value of a variable and assigns the result to the variable.


variable 
-= 
expression

Parts

variable

Required. Any numeric variable.

expression

Required. Any numeric expression.

Example

The following example uses the -= operator to subtract one Integer variable from another and assign the result to the latter variable.

Dim var1 As Integer = 10
Dim var2 As Integer = 3
var1 -= var2 ' The value of var1 is now 7.

See Also

&= Operator, *= Operator, += Operator, - Operator, /= Operator, = Operator, \= Operator, ^= Operator

/ Operator

Divides two numbers and returns a floating-point result.


number1 
/ 
number2

Parts

result

Required. Any numeric variable.

number1

Required. Any numeric expression.

number2

Required. Any numeric expression.

Result

The result is the quotient of number1 divided by number2.

Supported Types

Byte, Short, Integer, Long, Single, Double, Decimal

Remarks

The data type of result is usually Double. The following are exceptions to this rule:

If Then result is
One expression is Single and the other is any data type except Double Single.
Both expressions are Decimal data types Decimal. If a Decimal expression is divided by 0, a DividebyZero exception is raised. This exception only occurs with a Decimal expression.

If an expression is stated as Nothing, or is Empty, it is treated as zero.

Example

This example uses the / operator to perform floating-point division. The result is the quotient of the two operands.

Dim MyValue As Double
MyValue = 10 / 4 ' Returns 2.5.
MyValue = 10 / 3 ' Returns 3.333333.

See Also

\= Operator, \ Operator, Arithmetic Operators, Operator Precedence in Visual Basic, Operators Listed by Functionality

/= Operator

Divides the value of a variable by the value of an expression and assigns the result to the variable.


variable 
/= 
expression

Parts

variable

Required. Any numeric variable.

expression

Required. Any numeric expression.

Remarks

This statement assigns a Double to the variable on the left hand side. If Option Strict is On, variable must be a Double. If Option Strict is Off, an implicit conversion will be made and the resultant value assigned to variable, with a possible error at run time. For more information, see "Option Strict Statement."

Example

The following example uses the /= operator to divide one Integer variable by a second and assign the quotient to the first variable.

Dim var1 As Integer = 12
Dim var2 As Integer = 3
var1 /= var2 ' The value of var1 is now 4.

See Also

&= Operator, *= Operator, += Operator, -= Operator, / Operator, = Operator, \= Operator, ^= Operator

= Operator

Used to assign a value to a variable or property.


variable 
= 
value

Parts

variable

Any variable or any writable property.

value

Any literal, constant, or expression.

Remarks

The name on the left side of the equal sign can be a simple scalar variable, a property, or an element of an array. Properties on the left side of the equal sign can only be those properties that are writable at run time. When used, the value on the right side of the equation is assigned to the variable on the left side of the equation.

Example

This example demonstrates use of the assignment operator. The value on the right side of the expression is assigned to the variable on the left side of the expression.

Dim myInt as Integer
Dim myString as String
Dim myButton as System.Windows.Forms.Button
Dim myObject as Object
myInt = 42
myString = "This is an example of a string literal"
myButton = New System.Windows.Forms.Button()
myObject = myInt
myObject = myString
myObject = myButton

See Also

&= Operator, *= Operator, += Operator, -= Operator, /= Operator, \= Operator, ^= Operator

\ Operator

Divides two numbers and returns an integer result.


number1 
\ 
number2

Parts

number1

Required. Any numeric expression of an integral type.

number2

Required. Any numeric expression of an integral type.

Supported Types

Byte, Short, Integer, or Long

Result

The result is the integer quotient of number1 and number2, dropping the remainder.

Remarks

Before division is performed, any floating-point numeric expressions are coerced to Byte, Short, Integer, or Long expressions if Option Strict is Off. If Option Strict is On, a compiler error results.

The data type of the result is Byte, Short, Integer, or Long. Any fractional portion is truncated.

If any expression is stated as Nothing, or Empty, it is treated as zero. Attempting to perform integer division by zero causes a DivideByZeroExeception to be thrown.

Example

This example uses the \ operator to perform integer division. The result is an integer representing the integer quotient of the two operands.

Dim myValue As Integer
myValue = 11 \ 4 ' Returns 2.
myValue = 9 \ 3 ' Returns 3.
myValue = 100 \ 3 ' Returns 33.
MyValue = 67 \ -3 ' Returns -22.

See Also

\= Operator, / Operator, Arithmetic Operators, Operator Precedence in Visual Basic, Operators Listed by Functionality

\= Operator

Divides the value of a variable by the value of an expression and assigns the integer result to the variable.


variable 
\= 
expression

Parts

variable

Required. Any numeric variable.

expression

Required. Any numeric expression.

Remarks

For further information on integer division, see "\ Operator."

Example

The following example uses the \= operator to divide one Integer variable by a second and assign the integer result to the first variable.

Dim var1 As Integer = 10
Dim var2 As Integer = 3
var1 \= var2 ' The value of var1 is now 3.

See Also

&= Operator, *= Operator, += Operator, -= Operator, /= Operator, = Operator, \ Operator, ^= Operator

^ Operator

Raises a number to the power of another number.


Number 
^ 
exponent

Parts

number

Required. Any numeric expression.

exponent

Required. Any numeric expression.

Result

The result value will be number raised to the exponent power.

Supported Types

Double. All operands of a different type will be converted to Double.

Remarks

Number can be negative only if exponent is an integer value. When more than one exponentiation is performed in a single expression, the ^ operator is evaluated as it is encountered from left to right.

Usually, the data type of result is Double.

Example

This example uses the ^ operator to raise a number to the power of an exponent. The result is the first operand raised to the power of the second.

Dim myValue As Double
myValue = 2 ^ 2 ' Returns 4.
myValue = 3 ^ 3 ^ 3 ' Returns 19683.
myValue = (-5) ^ 3 ' Returns -125.
myValue = (-5) ^ 4 ' Returns 625.

See Also

^= Operator, Arithmetic Operators, Operator Precedence in Visual Basic, Operators Listed by Functionality

^= Operator

Raises the value of a variable to the power of an expression and assigns the result back to the variable.


variable 
^= 
expression

Parts

variable

Required. Any numeric variable.

expression

Required. Any numeric expression.

Example

The following example uses the ^= operator to raise the value of one Integer variable to the power of a second variable and assign the result to the first variable.

Dim var1 As Integer = 10
Dim var2 As Integer = 3
var1 ^= var2 ' The value of var1 is now 1000.

See Also

&= Operator, *= Operator, += Operator, -= Operator, /= Operator, = Operator, \= Operator, ^ Operator

Add Method

Adds a member to a Collection object.


Public Sub Add( _
ByVal Item As Object, _
Optional ByVal Key As String, _
Optional ByVal { Before | After } As Object = Nothing _
)

Parameters

Item

Required. An object of any type that specifies the member to add to the collection.

Key

Optional. A unique String expression that specifies a key string that can be used instead of a positional index to access a member of the collection.

Before

Optional. An expression that specifies a relative position in the collection. The member to be added is placed in the collection before the member identified by the Before argument. If Before is a numeric expression, it must be a number from 1 to the value of the collection's Count property. If Before is a String expression, it must correspond to the key string specified when the member being referred to was added to the collection. You cannot specify both Before and After.

After

Optional. An expression that specifies a relative position in the collection. The member to be added is placed in the collection after the member identified by the After argument. If After is a numeric expression, it must be a number from 1 to the value of the collection's Count property. If After is a String expression, it must correspond to the key string specified when the member referred to was added to the collection. You cannot specify both Before and After.

Exceptions/Error Codes

Exception type Error number Condition
ArgumentException 5 Both Before and After are specified, or argument does not refer to an existing member of the collection.
ArgumentException 5 The specified Key already exists.

Remarks

The Before or After argument must refer to an existing member of the collection; otherwise, an error occurs.

An error also occurs if a specified Key value matches the key for an existing member of the collection.

Example

This example uses the Add method to add Child objects—instances of a class called Child containing a Public property Name—to a collection called Family. To see how this works, create a Form with two Buttons and set their Text properties to Add and List. Add the Child class definition and the Family declaration to the form code. Modify the Click events for the Add and List buttons as shown. The Add button allows you to add children. The List button will display the names of all the children.

Public Class Child
Public Name As String
Sub New(ByVal newName As String)
Name = newName
End Sub
End Class
Private family As New Collection() ' Create a Collection object.
Private Sub Add_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim newName As String
newName = InputBox("Name of new family member: ")
If newName <> "" Then
family. Add(New Child(newName), newName )
End If
End Sub
Private Sub List_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Dim aChild As Child
For Each aChild In family
MsgBox(aChild.Name)
Next
End Sub

See Also

Item Property, Remove Method, ArgumentException

Applies To

Collection Object

AddHandler Statement

Associates an event with an event handler.


AddHandler 
event, 
AddressOf 
eventhandler

Parts

event

The name of the event to handle.

eventhandler

The name of a procedure that will handle the event.

Remarks

The AddHandler and RemoveHandler statements allow you to start and stop event handling at any time during program execution.

Example

Sub TestEvents()
Dim Obj As New Class1()
' Associate an event handler with an event.
AddHandler Obj.Ev_Event, AddressOf EventHandler
Obj.CauseSomeEvent() ' Ask the object to raise an event.
End Sub
Sub EventHandler()
' This procedure handles events raised by the object Obj.
MsgBox("EventHandler caught event.") ' Handle the event.
End Sub
Public Class Class1
Public Event Ev_Event() ' Declare an event.
Sub CauseSomeEvent()
RaiseEvent Ev_Event() ' Raise an event.
End Sub
End Class

See Also

RemoveHandler Statement, Handles

AddressOf Operator

Creates a procedure delegate instance that references the specific procedure.



AddressOf procedurename

The required procedurename specifies the procedure that will be referenced by the newly created procedure delegate.

Remarks

The AddressOf operator creates a function delegate that points to the function specified by procedurename. When the specified procedure is an instance method then the function delegate refers to both the instance and the method so that when the function delegate is invoked the specified method of the specified instance is called.

The AddressOf operator can be used as the operand of a delegate constructor or it can be used in a context in which the type of the delegate can be determined by the compiler.

Example

This example uses the AddressOf operator to designate a delegate to handle the Click event of a button.

Public Sub ButtonClickHandler(ByVal sender As Object, e As _
System.EventArgs)
' Implementation code omitted.
End Sub
Public Sub New()
AddHandler Button1.Click, AddressOf ButtonClickHandler
' Additional code omitted.
End Sub

The following example uses the AddressOf operator to designate the startup function for a thread.

Public Sub CountSheep()
Dim i As Integer = 1 ' Sheep don't count from 0.
Do While (True) ' Endless loop.
Console.WriteLine("Sheep " & i & " Baah")
i = i + 1
Thread.Sleep(1000) 'Wait 1 second.
Loop
End Sub
Sub UseThread()
Dim t As New System.Threading.Thread( AddressOf CountSheep)
t.Start()
End Sub

See Also

Declare Statement, Function Statement, Sub Statement

Alias

The Alias keyword indicates that an external procedure has another name in its DLL.

The Alias keyword is used in this context:

Declare Statement

See Also

Visual Basic Language Keywords

And Operator

Performs a logical conjunction on two Boolean expressions, or bitwise conjunction on two numeric expressions.


result 
= 
expression1 
And 
expression2

Parts

result

Required. Any Boolean or numeric expression. The result for Boolean comparison is the Boolean result of comparison of the two expressions. The result for numeric comparison is a numeric value resulting from the bitwise conjunction of two numeric expressions

expression1

Required. Any Boolean or numeric expression.

expression2

Required. Any Boolean or numeric expression.

Remarks

For Boolean comparison, if both expression1 and expression2 evaluate to True, result is True. If expression1 evaluates to True and expression2 evaluates to False, result is False. If expression1 evaluates to False, and expression2 evaluates to True, the result is False. The following table illustrates how result is determined:

If expression1 is And expression2 is Value of result is
True True True
True False False
False True False
False False False

When applied to numeric values, the And operator performs a bitwise comparison of identically positioned bits in two numeric expressions and sets the corresponding bit in result according to the following table:

If bit in expression1 is And bit in expression2 is The result is
0 0 0
0 1 0
1 0 0
1 1 1

NOTE:
Since the logical/bitwise operators have a lower precedence than other arithmetic and relational operators, any bitwise operations should be enclosed in parentheses to insure accurate execution.

If the operands consist of one Boolean expression and one numeric expression, the result Boolean expression will be converted to a numeric value (–1 for True, and 0 for False) and the bitwise operation will result.

Example

This example uses the And operator to perform a logical conjunction on two expressions. The result is a Boolean value that represents whether the entire conjoined expression is true.

Dim A As Integer = 10
Dim B As Integer = 8
Dim C As Integer = 6
Dim myCheck As Boolean
myCheck = A > B And B > C ' Returns True.
myCheck = B > A And B > C ' Returns False.

This example uses the And operator to perform logical conjunction of the individual bits of two numeric expressions. The bit in the result pattern is set if the corresponding bits in the operands are both set.

Dim A As Integer = 10
Dim B As Integer = 8
Dim C As Integer = 6
Dim myCheck As Integer
myCheck = (A And B) ' Returns 8.
myCheck = (A And C) ' Returns 2.
myCheck = (B And C) ' Returns 0.

See Also

Logical/Bitwise Operators, Operator Precedence in Visual Basic, Operators Listed by Functionality, AndAlso Operator, Logical Operators

AndAlso Operator

Performs short-circuiting logical conjunction on two expressions.


result 
= 
expression1 
AndAlso 
expression2

Parts

result

Required. Any Boolean expression. The result is the Boolean result of comparison of the two expressions.

expression1

Required. Any Boolean expression.

expression2

Required. Any Boolean expression.

Remarks

If both expression1 and expression2 evaluate to True, result is True. If expression1 evaluates to True and expression2 evaluates to False, result is False. If expression1 evaluates to False, expression2 is not evaluated, and result is False (the operator is said to have short-circuited the expression). The following table illustrates how result is determined:

If expression1 is And expression2 is Value of result is
True True True
True False False
False (not evaluated) False

Example

This example uses the AndAlso operator to perform a logical conjunction on two expressions. The result is a Boolean value that represents whether the entire conjoined expression is true. If the first expression is False, the second is not evaluated.

Dim A As Integer = 10
Dim B As Integer = 8
Dim C As Integer = 6
Dim myCheck As Boolean
myCheck = A > B AndAlso B > C ' True.
myCheck = B > A AndAlso B > C ' False. Second expression not evaluated.
myCheck = A > B AndAlso C > B ' False. Second expression evaluated.
' This example demonstrates using the AndAlso operator to search through
' array values. If i is greater than the upper bound of the array, it does
' attempt to find a corresponding value in the array.
Dim i As Integer = 0
While i <= UBound(arr) AndAlso arr(i) <> SearchValue
i += 1
End While

See Also

Logical/Bitwise Operators, Operator Precedence in Visual Basic, Operators Listed by Functionality, Logical Operators

Ansi

The Ansi keyword indicates that strings are converted to American National Standards Institute (ANSI) values regardless of the name of the method being declared.

The Ansi keyword is used in this context:

Declare Statement

See Also

Visual Basic Language Keywords

AppActivate Function

Activates an application window.


Public Overloads Sub AppActivate( _
ByVal { Title As String | ProcessID As Integer } _
)

Parameters

Title

String expression specifying the title in the title bar of the application window you want to activate. You can use the task ID returned by the Shell function.

ProcessID

Integer specifying the Win32® Process ID number assigned to this process.

Exceptions/Errors

Exception type Error number Condition
ArgumentException 5 ProcessID is not found.

Remarks

The AppActivate function changes the focus to the named application or window, but does not affect whether it is maximized or minimized. Focus moves from the activated application window when the user takes some action to change the focus or close the window. Use the Shell function to start an application and set the window style.

You can use AppActivate only with processes that own windows. Most console applications do not own windows, which means that they do not appear in the list of processes that AppActivate searches. When running from a console application, the system creates a separate process to run the application and returns the output to the console process. Consequently, when the current Process ID is requested, you get the created process's Process ID rather than the console application's Process ID.

At run time the AppActivate function activates any running application whose title matches Title or whose Process ID matches ProcessID. If there is no exact match, it activates any application whose title string begins with Title. If there is more than one application named by Title, the AppActivate function activates one at random.

Example

This example illustrates various uses of the AppActivate function to activate an application window. The Shell procedures assume the applications are in the paths specified.

Dim notepadID As Integer
' Activate a running notepad process.
AppActivate("Untitled - Notepad" )
' AppActivate can also use the return value of the Shell function.
' Shell runs a new instance of notepad.
notepadID = Shell("C:\WINNT\NOTEPAD.EXE", AppWinStyle.MinimizedNoFocus)
' Activate the new instance of notepad.
AppActivate(notepadID )

See Also

Shell Function

AppWinStyle Enumeration

When you issue Shell commands, you can use the following enumeration members in your code in place of the actual values.

AppWinStyle Enumeration Members

The Style argument takes the following AppWinStyle enumeration members:

Member Constant Description
Hide vbHide Window is hidden and focus is passed to the hidden window.
NormalFocus vbNormalFocus Window has focus and is restored to its original size and position.
MinimizedFocus vbMinimizedFocus Window is displayed as an icon with focus.
MaximizedFocus vbMaximizedFocus Window is maximized with focus.
NormalNoFocus vbNormalNoFocus Window is restored to its most recent size and position. The currently active window remains active.
MinimizedNoFocus vbMinimizedNoFocus Window is displayed as an icon. The currently active window remains active.

See Also

Shell Function

As

The As keyword introduces an As clause, which identifies a data type.

The As keyword is used in these contexts:

Const Statement
Declare Statement
Delegate Statement
Dim Statement
Enum Statement
Event Statement
Function Statement
Property Statement
Sub Statement
Try...Catch...Finally Statements

See Also

Visual Basic Language Keywords

Asc, AscW Functions

Returns an Integer value representing the character code corresponding to a character.


Public Overloads Function Asc(ByVal 
String 
As Char) As Integer
Public Overloads Function AscW(ByVal String As Char) As Integer

-or-


Public Overloads Function Asc(ByVal 
String 
As String) As Integer
Public Overloads Function AscW(ByVal String As String) As Integer

Parameter

String

Required. Any valid Char or String expression. If String is a String expression, only the first character of the string is used for input. If String is Nothing or contains no characters, an ArgumentException error occurs.

Exceptions/Errors

Exception type Error number Condition
ArgumentException 5 String is not specified or is zero length.

Remarks

Asc returns the code point, or character code, for the input character. This can be 0 through 255 for single-byte character set (SBCS) values and –32768 through 32767 for double-byte character set (DBCS) values. The returned value depends on the code page for the current thread, which is contained in the ANSICodePage property of the TextInfo class. TextInfo.ANSICodePage can be obtained by specifying System.Globalization.CultureInfo.CurrentCulture.TextInfo.ANSICodePage.

AscW returns the Unicode code point for the input character. This can be 0 through 65535. The returned value is independent of the culture and code page settings for the current thread.

Example

This example uses the Asc function to return Integer character codes corresponding to the first letter in each string.

Dim MyInt As Integer
MyInt = Asc("A" ) ' MyInt is set to 65.
MyInt = Asc("a" ) ' MyInt is set to 97.
MyInt = Asc("Apple" ) ' MyInt is set to 65.

See Also

Chr, ChrW Functions; Conversion Functions; Type Conversion Functions

Assembly

The Assembly keyword indicates that an attribute block at the beginning of a source file applies to the entire assembly and not only to the current module.

Auto

The Auto keyword indicates that strings are converted according to common language runtime rules based on the name of the method being declared.

The Auto keyword is used in this context:

Declare Statement

See Also

Visual Basic Language Keywords

Beep Function

Sounds a tone through the computer's speaker.


Public Sub Beep()

Remarks

The pitch and duration of the beep depend on your hardware and system software, and therefore vary among computers.

Example

This example uses the Beep function to sound a long, uninterrupted tone through the computer's speaker.

Dim I As Integer
For I = 1 To 100 ' Loop 100 times.
Beep ' Sound a tone.
Next I

See Also

Visual Basic Run-Time Library Members

Boolean Data Type

Boolean variables are stored as 16-bit (2-byte) numbers, but they can only be True or False. Use the keywords True and False to assign one of the two states to Boolean variables.

When numeric data types are converted to Boolean values, 0 becomes False and all other values become True. When Boolean values are converted to numeric types, False becomes 0 and True becomes –1.


NOTE:
You should never write code that relies on equivalent numeric values for True and False. Whenever possible, you should restrict usage of Boolean variables to the logical values for which they are designed. If it is necessary to mix Boolean and numeric values, be sure to use the appropriate conversion keywords.

The equivalent .NET data type is System.Boolean.

See Also

Data Type Summary, Integer Data Type, Type Conversion Functions, Conversion Summary

ByRef

The ByRef keyword indicates that an argument is passed in such a way that the called procedure can change the value of a variable underlying the argument in the calling code.

The ByRef keyword is used in these contexts:

Declare Statement
Function Statement
Sub Statement

See Also

Visual Basic Language Keywords

Byte Data Type

Byte variables are stored as unsigned 8-bit (1-byte) numbers ranging in value from 0 through 255.

The Byte data type is used for containing binary data.


NOTE:
The Byte data type can be converted to the Short, Integer, Long, Single, Double, or Decimal data type without encountering a System.OverflowException error.

The equivalent .NET data type is System.Byte.

See Also

Data Type Summary, Integer Data Type, Short Data Type, Type Conversion Functions, Conversion Summary

ByVal

The ByVal keyword indicates that an argument is passed in such a way that the called procedure or property cannot change the value of a variable underlying the argument in the calling code.

The ByVal keyword is used in these contexts:

Declare Statement
Function Statement
Property Statement
Sub Statement

See Also

Visual Basic Language Keywords

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 3 Customer Reviews
  • Anonymous

    Posted August 10, 2012

    Hate this

    Stupid

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted January 27, 2011

    No text was provided for this review.

  • Anonymous

    Posted March 20, 2011

    No text was provided for this review.

Sort by: Showing all of 3 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)