VB.NET Language in a Nutshell, Second Edition

Book description

With the release of the Microsoft .NET platform comes a new version of Visual Basic dramatically unlike its predecessors. So extensive are the changes, in fact, that some VB programmers argue that Visual Basic .NET is an entirely new programming language. In the updated second edition of this popular book, you will find complete documentation for the Visual Basic .NET language.

Beginning with a brief overview of the language, VB.NET Language in a Nutshell covers basic programming concepts, and introduces the .NET Framework Class Library and programming with attributes. The bulk of the book consists of an alphabetical reference to Visual Basic .NET statements, procedures, functions, and objects. Each entry has a standardized listing containing the following information:

  • Its syntax, using standard coding conventions

  • Differences in the operation of the keyword in Visual Basic .NET and in VB 6.0

  • A list of arguments accepted by the function or procedure

  • A description of the data type returned by a function

  • The finer points of a language element?s usage that are often omitted from or blurred over by other sources

  • Tips and warnings that include undocumented behaviors and practical applications for particular language elements

  • An invaluable section for diagnosing or avoiding potential programming problems

  • A cross-reference to related keywords

On the CD-ROM (included with print edition of the book) is a plug-in that adds a copy of the book's language reference to the dynamic help within Visual Studio .NET. The plug-in requires any edition of Visual Basic .NET or Visual Studio .NET.

No matter how much experience you have programming with VB, you want this book close by, both as a standard reference guide and as a tool for troubleshooting and identifying programming problems.

Table of contents

  1. VB.NET Language in a Nutshell, 2nd Edition
    1. Preface
      1. Why Another VB Book?
      2. Who This Book Is For
        1. Readers New to Visual Basic
        2. VB and VBScript Developers New to VB.NET
        3. Existing VB.NET Developers
      3. How This Book Is Structured
        1. The Format of the Language Reference
      4. Conventions Used in This Book
      5. How to Contact Us
      6. Acknowledgments
    2. I. The Basics
      1. 1. Introduction
        1. Why VB.NET?
        2. What Is VB.NET?
          1. Object Orientation
          2. A Common Type System
          3. Access to System Services: The Framework Class Library
          4. A Common Runtime Environment
        3. What Can You Do with VB.NET?
      2. 2. Program Structure
        1. Getting a VB Program to Run
          1. Console Applications
          2. Windows Forms Applications
        2. The Structure of a VB Program
          1. Events: The Starting Point
            1. Windows Forms events
            2. ASP.NET events
            3. Event arguments
          2. Calling Routines from Event Handlers
          3. Writing Custom Procedures
            1. Functions
            2. Sub procedures
            3. Property procedures
          4. Controlling Execution Flow
            1. Calling sub and function procedures
            2. Setting and retrieving property values
      3. 3. Variables and Data Types
        1. Variables
          1. Variable Scope
            1. Local variables: block-level and procedure-level scope
            2. Module-level and project-level scope
              1. Private access
              2. Friend access
              3. Public access
          2. Variable Lifetime
            1. Static variables
        2. Declaring Variables and Constants
        3. Data Types
          1. Value and Reference Types
          2. VB Data Types: A Summary
          3. Simple Data Types in Visual Basic
            1. Boolean data type
            2. Byte data type
            3. Char data type
            4. Date data type
            5. Decimal data type
            6. Double data type
            7. Integer data type
            8. Long data type
            9. Object data type
            10. Short data type
            11. Single data type
            12. String data type
            13. Structure data type: user-defined types
          4. Data Type Conversion
        4. Arrays
          1. Definition of Array
          2. Dimension of an Array
          3. Size of an Array
          4. Arrays in VB.NET
            1. Redimensioning arrays
        5. Object Variables and Their Binding
          1. Late Binding Versus Early Binding
        6. The Collection Object
        7. Parameters and Arguments
          1. Passing Arguments
          2. Passing Objects
          3. Optional Arguments
          4. ParamArray
      4. 4. Introduction to Object-Oriented Programming
        1. Why Learn Object-Oriented Techniques?
        2. Principles of Object-Oriented Programming
          1. Abstraction
          2. Encapsulation
          3. Interfaces
        3. Classes and Objects
          1. Class Modules in VB.NET
          2. Class Members
          3. The Public Interface of a VB.NET Class
          4. Objects
          5. Properties
          6. Instance and Shared Members
          7. Class Constructors
          8. Finalize, Dispose, and Garbage Collection
        4. Inheritance
          1. Permission to Inherit
          2. Overriding
          3. Rules of Inheritance
          4. MyBase, MyClass, and Me
          5. Shadowing
        5. Interfaces, Abstract Members, and Classes
          1. Interfaces Revisited
        6. Polymorphism and Overloading
          1. Overloading
          2. Polymorphism
        7. Accessibility in Class Modules
          1. Member Inheritance
          2. Member Accessibility
      5. 5. The .NET Framework: General Concepts
        1. Namespaces
        2. Common Language Runtime (CLR), Managed Code, and Managed Data
        3. Managed Execution
        4. Assemblies
        5. Assemblies and VB.NET
      6. 6. The .NET Framework Class Library
        1. The System Namespace
          1. Data Type Conversion
          2. The Array Class
          3. The Math Class
          4. The String Class
        2. Other Namespaces
          1. System.Collections
          2. System.Data
          3. System.IO
          4. System.Text.RegularExpressions
          5. System.Windows.Forms
      7. 7. Delegates and Events
        1. Delegates
          1. Using a Delegate to Call a Method
          2. Using a Delegate as a Function Pointer
        2. Events and Event Binding
          1. Control-Related Events
          2. WithEvents
          3. AddHandler and RemoveHandler
      8. 8. Attributes
        1. Syntax and Use
        2. Defining a Custom Attribute
        3. Using a Custom Attribute
      9. 9. Error Handling in VB.NET
        1. Error Detection and Error Handling
        2. Runtime Error Handling
          1. Unstructured Error Handling
            1. The Err object
            2. Dealing with runtime errors
              1. In-line error handling
              2. Centralized error handling
              3. No enabled error-handler
          2. Structured Exception Handling
            1. Try...Catch...Finally
            2. Exception classes
        3. Dealing with Logical Errors
          1. Detecting Logical Errors
          2. Where to Handle a Logical Error
            1. Handling the error on the spot
            2. Handling the error in the offending procedure’s error handler
            3. Passing the error to the calling procedure
        4. Error Constants
    3. II. Reference
      1. 10. The Language Reference
        1. #Const Directive
        2. #If . . . Then . . . #Else Directive
        3. #Region...#End Region Directive
        4. Abs Function
        5. Acos Function
        6. AddHandler Statement
        7. AddressOf Operator
        8. AppActivate Procedure
        9. Application Class
        10. Application.CompanyName Property
        11. Application.DoEvents Method
        12. Application.ExecutablePath Property
        13. Application.ProductName Property
        14. Application.ProductVersion Property
        15. Array Class
        16. Array.BinarySearch Method
        17. Array.Copy Method
        18. Array.IndexOf Method
        19. Array.LastIndexOf Method
        20. Array.Reverse Method
        21. Array.Sort Method
        22. Asc, AscW Functions
        23. AssemblyVersion Attribute
        24. Asin Function
        25. Atan Function
        26. Atan2 Function
        27. AttributeUsage Attribute
        28. Beep Procedure
        29. Call Statement
        30. CallByName Function
        31. CBool Function
        32. CByte Function
        33. CChar Function
        34. CDate Function
        35. CDbl Function
        36. CDec Function
        37. Ceiling Function
        38. ChDir Procedure
        39. ChDrive Procedure
        40. Choose Function
        41. Chr, ChrW Functions
        42. CInt Function
        43. Class Statement
        44. Clipboard Class
        45. Clipboard.GetDataObject Method
        46. Clipboard.SetDataObject Method
        47. CLng Function
        48. CLSCompliant Attribute
        49. CObj Function
        50. Collection Class
        51. Collection.Add Method
        52. Collection.Count Property
        53. Collection.Item Method
        54. Collection.Remove Method
        55. ColorDialog Class
        56. COMClass Attribute
        57. Command Function
        58. Const Statement
        59. Cos Function
        60. Cosh Function
        61. CreateObject Function
        62. CShort Function
        63. CSng Function
        64. CStr Function
        65. CType Function
        66. CurDir Function
        67. DateAdd Function
        68. DateDiff Function
        69. DatePart Function
        70. DateSerial Function
        71. DateString Property
        72. DateValue Function
        73. Day Function
        74. DDB Function
        75. Debug Class
        76. Debug.Assert Method
        77. Debug.AutoFlush Property
        78. Debug.Close Method
        79. Debug.Flush Method
        80. Debug.Indent Method
        81. Debug.IndentLevel Property
        82. Debug.IndentSize Property
        83. Debug.Listeners Property
        84. Debug.Unindent Method
        85. Debug.Write Method
        86. Debug.WriteIf Method
        87. Debug.WriteLine Method
        88. Debug.WriteLineIf Method
        89. Declare Statement
        90. DefaultMember Attribute
        91. Delegate Statement
        92. DeleteSetting Procedure
        93. Dim Statement
        94. Dir Function
        95. DirectCast Function
        96. Directory Class
        97. Directory.CreateDirectory Method
        98. Directory.Delete Method
        99. Directory.Exists Method
        100. Directory.GetCreationTime Method
        101. Directory.GetDirectories Method
        102. Directory.GetDirectoryRoot Method
        103. Directory.GetFiles Method
        104. Directory.GetFileSystemEntries Method
        105. Directory.GetLogicalDrives Method
        106. Directory.GetParent Method
        107. Directory.Move Method
        108. Do...Loop Statement
        109. E Field
        110. End... Statement
        111. Enum Statement
        112. Environ Function
        113. EOF Function
        114. Erase Statement
        115. Erl Property
        116. Err Object
        117. Err.Clear Method
        118. Err.Description Property
        119. Err.GetException Method
        120. Err.HelpContext Property
        121. Err.HelpFile Property
        122. Err.LastDLLError Property
        123. Err.Number Property
        124. Err.Raise Method
        125. Err.Source Property
        126. Error Statement
        127. ErrorToString Function
        128. Event Statement
        129. Exception Class
        130. Exit Statement
        131. Exp Function
        132. File Class
        133. File.Exists Method
        134. FileAttr Function
        135. FileClose Procedure
        136. FileCopy Procedure
        137. FileDateTime Function
        138. FileGet, FileGetObject Procedures
        139. FileLen Function
        140. FileOpen Procedure
        141. FilePut, FilePutObject Procedures
        142. FileWidth Procedure
        143. Filter Function
        144. Fix Function
        145. Flags Attribute
        146. Floor Function
        147. FontDialog Class
        148. For...Next Statement
        149. For Each...Next Statement
        150. Format Function
        151. FormatCurrency, FormatNumber, FormatPercent Functions
        152. FormatDateTime Function
        153. FreeFile Function
        154. Friend Keyword
        155. Function Statement
        156. FV Function
        157. Get Statement
        158. GetAllSettings Function
        159. GetAttr Function
        160. GetChar Function
        161. GetObject Function
        162. GetSetting Function
        163. GetTimer Function
        164. GetType Operator
        165. GoTo Statement
        166. Guid Attribute
        167. Handles Keyword
        168. Hashtable Class
        169. Hashtable.Add Method
        170. Hashtable.Clear Method
        171. Hashtable.ContainsKey Method
        172. Hashtable.ContainsValue Method
        173. Hashtable.CopyTo Method
        174. Hashtable.Count Property
        175. Hashtable.Item Property
        176. Hashtable.Keys Property
        177. Hashtable.Remove Method
        178. Hashtable.Values Property
        179. Hex Function
        180. Hour Function
        181. IDataObject Interface
        182. IDataObject.GetData Method
        183. IDataObject.GetDataPresent Method
        184. IDataObject.GetFormats Method
        185. IEEERemainder Function
        186. If...Then...Else Statement
        187. IIf Function
        188. Implements Keyword
        189. Implements Statement
        190. Imports Statement
        191. Inherits Statement
        192. Input Procedure
        193. InputBox Function
        194. InputString Function
        195. InStr Function
        196. InStrRev Function
        197. Int Function
        198. Interface Statement
        199. IPmt Function
        200. IRR Function
        201. Is Operator
        202. IsArray Function
        203. IsDate Function
        204. IsDBNull Function
        205. IsError Function
        206. IsNothing Function
        207. IsNumeric Function
        208. IsReference Function
        209. Join Function
        210. Kill Procedure
        211. LBound Function
        212. LCase Function
        213. Left Function
        214. Len Function
        215. Like Operator
        216. LineInput Function
        217. Loc Function
        218. Lock Procedure
        219. LOF Function
        220. Log Function
        221. Log10 Function
        222. LSet Function
        223. LTrim Function
        224. MarshalAs Attribute
        225. Max Function
        226. Me Operator
        227. Mid Function
        228. Mid Statement
        229. Min Function
        230. Minute Function
        231. MIRR Function
        232. MkDir Procedure
        233. Mod Operator
        234. Module...End Module Statement
        235. Month Function
        236. MonthName Function
        237. MsgBox Function
        238. MTAThread Attribute
        239. MyBase Keyword
        240. MyClass Keyword
        241. Namespace Statement
        242. Now Property
        243. NPer Function
        244. NPV Function
        245. Obsolete Attribute
        246. Oct Function
        247. On Error Statement
        248. OpenFileDialog Class
        249. Option Compare Statement
        250. Option Explicit Statement
        251. Option Strict Statement
        252. Out Attribute
        253. ParamArray Attribute
        254. Partition Function
        255. Pi Field
        256. Pmt Function
        257. Pow Function
        258. PPmt Function
        259. Print, PrintLine Procedures
        260. Private Statement
        261. Property Statement
        262. Protected Keyword
        263. Public Statement
        264. PV Function
        265. QBColor Function
        266. Queue Class
        267. Queue.Clear Method
        268. Queue.Contains Method
        269. Queue.CopyTo Method
        270. Queue.Count Property
        271. Queue.Dequeue Method
        272. Queue.Enqueue Method
        273. Queue.Peek Method
        274. Queue.ToArray Method
        275. RaiseEvent Statement
        276. Randomize Procedure
        277. Rate Function
        278. ReDim Statement
        279. Rem Statement
        280. RemoveHandler Statement
        281. Rename Procedure
        282. Replace Function
        283. Reset Procedure
        284. Resume Statement
        285. Return Statement
        286. RGB Function
        287. Right Function
        288. RmDir Procedure
        289. Rnd Function
        290. Round Function
        291. RSet Function
        292. RTrim Function
        293. SaveFileDialog Class
        294. SaveSetting Procedure
        295. ScriptEngine Property
        296. ScriptEngineBuildVersion Property
        297. ScriptEngineMajorVersion Property
        298. ScriptEngineMinorVersion Property
        299. Second Function
        300. Seek Function
        301. Seek Procedure
        302. Select Case Statement
        303. Send, SendWait Methods
        304. Set Statement
        305. SetAttr Procedure
        306. Shadows Keyword
        307. Shell Function
        308. Sign Function
        309. Sin Function
        310. Sinh Function
        311. SLN Function
        312. Space Function
        313. Spc Function
        314. Split Function
        315. Sqrt Function
        316. Stack Class
        317. Stack.Clear Method
        318. Stack.Contains Method
        319. Stack.CopyTo Method
        320. Stack.Count Property
        321. Stack.Peek Method
        322. Stack.Pop Method
        323. Stack.Push Method
        324. Stack.ToArray Method
        325. STAThread Attribute
        326. Static Statement
        327. Stop Statement
        328. Str Function
        329. StrComp Function
        330. StrConv Function
        331. StrDup Function
        332. StrReverse Function
        333. Structure...End Structure Statement
        334. Sub Statement
        335. Switch Function
        336. SYD Function
        337. SyncLock Statement
        338. SystemTypeName Function
        339. Tab Function
        340. Tan Function
        341. Tanh Function
        342. ThreadStatic Attribute
        343. Throw Statement
        344. TimeOfDay Property
        345. Timer Property
        346. TimeSerial Function
        347. TimeString Property
        348. TimeValue Function
        349. Today Property
        350. Trim Function
        351. Try...Catch...Finally Statement
        352. TypeName Function
        353. UBound Function
        354. UCase Function
        355. Unlock Procedure
        356. Val Function
        357. ValDec Function
        358. VarType Function
        359. VBFixedArray Attribute
        360. VBFixedString Attribute
        361. VbTypeName Function
        362. WebMethod Attribute
        363. WebService Attribute
        364. Weekday Function
        365. WeekdayName Function
        366. While...End While Statement
        367. With Statement
        368. WithEvents Keyword
        369. Write Procedure
        370. WriteLine Procedure
        371. Year Function
    4. III. Appendixes
      1. A. What’s New and Different in VB.NET
        1. Language Changes for VB.NET
          1. Data Types
            1. Strings
            2. Integer/Long data type changes
            3. Variant data type
            4. Other data type changes
          2. Variables and Their Declaration
            1. Variable declaration
            2. Variable initialization
            3. Variable scope changes
            4. Arrays and array declarations
            5. Structure/user-defined type declarations
          3. Boolean and Bitwise Operators
          4. Changes Related to Procedures
            1. Calling a procedure
            2. Default method of passing arguments
            3. Optional arguments
            4. Return statement
            5. Passing property parameters in procedures
            6. ParamArray parameters
          5. Miscellaneous Language Changes
            1. Line numbers
            2. On GoTo
            3. While
            4. GoSub and Return statements
        2. Changes to Programming Elements
          1. Constants
          2. String Functions
          3. Emptiness
          4. Graphical Functionality
          5. Mathematical Functionality
          6. Diagnostics
          7. Miscellaneous
        3. Obsolete Programming Elements
        4. Structured Exception Handling
        5. Changes in Object-Orientation
          1. Inheritance
          2. Overloading
          3. Object Creation
          4. Properties
            1. Default properties
            2. Property declarations
      2. B. Language Elements by Category
        1. Array Handling
        2. Clipboard
        3. Collection Objects
        4. Common Dialogs
        5. Conditional Compilation
        6. Conversion
          1. Data Type Conversion
          2. Other Conversion
        7. Date and Time
        8. Debugging
        9. Declaration
        10. Error Handling
        11. Filesystem
        12. Financial
        13. IDataObject Interface
        14. Information
        15. Input/Output
        16. Integrated Development Environment
        17. Interaction
        18. Mathematics
        19. Program Structure and Flow
        20. Programming
          1. Object Programming
          2. Miscellaneous Programming
        21. Registry
        22. String Manipulation
      3. C. Operators
        1. Arithmetic Operators
        2. Assignment Operators
        3. Concatenation Operators
        4. Comparison Operators
          1. The Is Operator
          2. The Like Operator
        5. Logical and Bitwise Operators
        6. Operator Precedence
      4. D. Constants and Enumerations
        1. Visual Basic Intrinsic Constants
        2. ControlChars Class
        3. Visual Basic Enumerations
          1. AppWinStyle Enumeration
          2. CallType Enumeration
          3. CompareMethod Enumeration
          4. DateFormat Enumeration
          5. DateInterval Enumeration
          6. DueDate Enumeration
          7. FileAttribute Enumeration
          8. FirstDayOfWeek Enumeration
          9. FirstWeekOfYear Enumeration
          10. MsgBoxResult Enumeration
          11. MsgBoxStyle Enumeration
          12. OpenAccess Enumeration
          13. OpenMode Enumeration
          14. OpenModeTypes Enumeration
          15. OpenShare Enumeration
          16. TriState Enumeration
          17. VariantType Enumeration
          18. VbStrConv Enumeration
      5. E. The VB.NET Command-Line Compiler
        1. Compiler Basics
        2. Command-Line Switches
          1. Output Filename and File Type
          2. Input Files
          3. Resources
          4. Code Generation
          5. Debugging
          6. Errors and Warnings
          7. Language
          8. Miscellaneous
          9. Advanced
        3. Using a Response File
      6. F. VB 6 Language Elements Not Supported by VB.NET
    5. Index
    6. Colophon

Product information

  • Title: VB.NET Language in a Nutshell, Second Edition
  • Author(s): Steven Roman PhD
  • Release date: April 2002
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596003081