Visual Basic .NET Language #vb.net Table of Contents About 1 Chapter 1: Getting started with Visual Basic .NET Language 2 Remarks 2 Versions 2 Examples 2 Hello World 2 Hello World on a Textbox upon Clicking of a Button 3 Region 4 Creating a simple Calculator to get familiar with the interface and code. 5 Chapter 2: Array 13 Remarks 13 Examples 13 Array definition 13 Zero-Based 13 Declare a single-dimension array and set array element values 14 Array initialization 14 Multidimensional Array initialization 14 Jagged Array Initialization 14 Null Array Variables 15 Referencing Same Array from Two Variables 15 Non-zero lower bounds 15 Chapter 3: BackgroundWorker 17 Examples 17 Using BackgroundWorker 17 Accessing GUI components in BackgroundWorker 18 Chapter 4: ByVal and ByRef keywords 19 Examples 19 ByVal keyword 19 ByRef keyword 19 Chapter 5: Classes 21 Introduction 21 Examples 21 Creating classes 21 Abstract Classes 21 Chapter 6: Conditions 23 Examples 23 IF...Then...Else 23 If operator 23 Chapter 7: Connection Handling 25 Examples 25 Public connection property 25 Chapter 8: Console 26 Examples 26 Console.ReadLine() 26 Console.WriteLine() 26 Console.Write() 26 Console.Read() 26 Console.ReadKey() 27 Prototype of command line prompt 27 Chapter 9: Data Access 29 Examples 29 Read field from Database 29 Simple Function to read from Database and return as DataTable 30 Get Scalar Data 31 Chapter 10: Date 32 Examples 32 Converting (Parsing) a String to a Date 32 Converting a Date To A String 32 Chapter 11: Debugging your application 33 Introduction 33 Examples 33 Debug in the console 33 Indenting your debug output 33 Debug in a text file 34 Chapter 12: Declaring variables 36 Syntax 36 Examples 36 Declaring and assigning a variable using a primitive type 36 Levels of declaration – Local and Member variables 39 Example of Access Modifiers 40 Chapter 13: Dictionaries 44 Introduction 44 Examples 44 Loop through a dictionary and print all entries 44 Create a dictionary filled with values 44 Getting a dictionary value 44 Checking for key already in dictionary - data reduction 45 Chapter 14: Disposable objects 46 Examples 46 Basic concept of IDisposable 46 Declaring more objects in one Using 47 Chapter 15: Enum 48 Examples 48 Enum definition 48 Member initialization 48 The Flags attribute 48 HasFlag() 49 String parsing 49 GetNames() 50 GetValues() 50 ToString() 51 Determine whether a Enum has FlagsAttribute specified or not 51 For-each flag (flag iteration) 52 Determine the amount of flags in a flag combination 53 Find the nearest value in a Enum 53 Chapter 16: Error Handling 55 Examples 55 Try...Catch...Finally Statement 55 Creating custom exception and throwing 55 Try Catch in Database Operation 56 The Un-catchable Exception 56 Critical Exceptions 57 Chapter 17: Extension methods 58 Remarks 58 Examples 58 Creating an extension method 58 Making the language more functional with extension methods 59 Padding Numerics 59 Getting Assembly Version From Strong Name 60 Chapter 18: File Handling 61 Syntax 61 Examples 61 Write Data to a File 61 Read All Contents of a File 61 Write Lines Individually to a Text File using StreamWriter 61 Chapter 19: File/Folder Compression 63 Examples 63 Creating zip archive from directory 63 Extracting zip archive to directory 63 Create zip archive dynamicaly 63 Adding File Compression to your project 63 Chapter 20: FTP server 65 Syntax 65 Examples 65 Download file from FTP server 65 Download file from FTP server when login required 65 Upload file to FTP server 65 Upload file to FTP server when login required 65 Chapter 21: Functions 66 Introduction 66 Examples 66 Defining a Function 66 Defining a Function #2 66 Chapter 22: GDI+ 67 Examples 67 Create Graphic Object 67 Draw Shapes 67 Fill Shapes 68 Text 69 Chapter 23: Generics 70 Examples 70 Create a generic class 70 Instance of a Generic Class 70 Define a 'generic' class 70 Use a generic class 70 Limit the possible types given 71 Create a new instance of the given type 71 Chapter 24: Google Maps in a Windows Form 73 Examples 73 How to use a Google Map in a Windows Form 73 Chapter 25: Introduction to Syntax 84 Examples 84 Comments 84 Intellisense Helper 84 Declaring a Variable 84 Modifiers 85 Writing a function 86 Object Initializers 87 Collection Initializer 88 Chapter 26: LINQ 91 Introduction 91 Examples 91 Projection 91 Selecting from array with simple condition 91 Mapping array by Select clause 91 Ordering output 92 Generating Dictionary From IEnumerable 92 Getting distinct values (using the Distinct method) 92 Chapter 27: Lists 94 Syntax 94 Examples 94 Create a List 94 Add items to a List 95 Remove items from a List 95 Retrieve items from a List 96 Loop trough items in list 96 Check if item exists in a List 97 Chapter 28: Looping 98 Examples 98 For...Next 98 For Each...Next loop for looping through collection of items 99 While loop to iterate while some condition is true 99 Do...Loop 100 Short Circuiting 101 Nested Loop 103 Chapter 29: Multithreading 104 Examples 104 Multithreading using Thread Class 104 Chapter 30: NullReferenceException 106 Remarks 106 Examples 106 Uninitialized variable 106 Empty Return 106 Chapter 31: OOP Keywords 108 Examples 108 Defining a class 108 Inheritance Modifiers (on classes) 108 Inherits 108 NotInheritable 108 MustInherit 109 Inheritance Modifiers (on properties and methods) 109 Overridable 109 Overrides 109 NotOverridable 109 MustOverride 110 MyBase 111 Me vs MyClass 112 Overloading 112 Shadows 113 Interfaces 114 Chapter 32: Operators 116 Remarks 116 Examples 116 Comparison 116 Assignment 117 Math 117 Widening and Narrowing 118 Operator Overloading 119 Bitwise 119 String Concatenation 119 Chapter 33: Option Explicit 121 Remarks 121 Examples 121 What is it? 121 How to switch it on? 121 Chapter 34: Option Infer 123 Examples 123 What is it? 123 How to enable/disable it 123 When to use type inference 124 Chapter 35: Option Strict 126 Syntax 126 Remarks 126 Examples 126 Why Use It? 126 How to Switch It On 127 Chapter 36: Random 129 Introduction 129 Remarks 129 Examples 129 Declaring an instance 129 Generate a random number from an instance of Random 130 Chapter 37: Reading compressed textfile on-the-fly 131 Examples 131 Reading .gz textfile line after line 131 Chapter 38: Recursion 132 Examples 132 Compute nth Fibonacci number 132 Chapter 39: Reflection 133 Examples 133 Retrieve Properties for an Instance of a Class 133 Get the members of a type 133 Get a method and invoke it 133 Create an instance of a generic type 134 Chapter 40: Short-Circuiting Operators (AndAlso - OrElse) 135 Syntax 135 Parameters 135 Remarks 135 Examples 135 AndAlso Usage 135 OrElse Usage 136 Avoiding NullReferenceException 136 OrElse 136 AndAlso 137 Chapter 41: Task-based asynchronous pattern 138 Examples 138 Basic usage of Async/Await 138 Using TAP with LINQ 138 Chapter 42: Threading 140 Examples 140 Performing thread-safe calls using Control.Invoke() 140 Performing thread-safe calls using Async/Await 140 Chapter 43: Type conversion 142 Syntax 142 Parameters 142 Examples 142 Converting Text of The Textbox to an Integer 142 Chapter 44: Unit Testing in VB.NET 144 Remarks 144 Examples 144 Unit Testing for Tax Calculation 144 Testing Employee Class assigned and derived Properties 146 Chapter 45: Using axWindowsMediaPlayer in VB.Net 150 Introduction 150 Examples 150 Adding the axWindowsMediaPlayer 150 Play a Multimedia File 152 Chapter 46: Using BackgroundWorker 154 Examples 154 Basic implementation of Background worker class 154 Chapter 47: Using Statement 155 Syntax 155 Examples 155 See examples under Disposable objects 155 Chapter 48: Visual Basic 14.0 Features 156 Introduction 156 Examples 156 Null conditional operator 156 NameOf operator 156 String interpolation 157 Read-Only Auto-Properties 158 Partial Modules and Interfaces 158 Multiline string literals 159 #Region directive improvements 159 Comments after implicit line continuation 160 Exception handling 160 Chapter 49: WinForms SpellCheckBox 163 Introduction 163 Examples 163 ElementHost WPF TextBox 163 Chapter 50: Working with Windows Forms 167 Examples 167 Using the default Form instance 167 Passing Data From One Form To Another 167 Chapter 51: WPF XAML Data Binding 169 Introduction 169 Examples 169 Binding a String in the ViewModel to a TextBox in the View 169 Credits 171 About You can share this PDF with anyone you feel could benefit from it, downloaded the latest version from: visual-basic--net-language It is an unofficial and free Visual Basic .NET Language ebook created for educational purposes. All the content is extracted from Stack Overflow Documentation, which is written by many hardworking individuals at Stack Overflow. It is neither affiliated with Stack Overflow nor official Visual Basic .NET Language. The content is released under Creative Commons BY-SA, and the list of contributors to each chapter are provided in the credits section at the end of this book. Images may be copyright of their respective owners unless otherwise specified. All trademarks and registered trademarks are the property of their respective company owners. Use the content presented in this book at your own risk; it is not guaranteed to be correct nor accurate, please send your feedback and corrections to [email protected] https://riptutorial.com/ 1 Chapter 1: Getting started with Visual Basic .NET Language Remarks Visual Basic .NET is the official successor to Microsoft's original Visual Basic programming language. Visual Basic [.NET] appears to have similarities to Python with the lack of semicolons and brackets, but shares with C++ the basic structure of functions. Curly braces are absent in VB .NET, but instead are replaced with phrases like End If, Next, and End Sub.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages185 Page
-
File Size-