- Information
- AI Chat
Visual Basic .NET III SEM NOTES Complete 5 units
Computer Science (Core 11)
Kristu Jayanti College
Preview text
🌠
VB BCA III SEM
####### Unit 1
####### What Does Visual Programming Language (VPL) Mean?
####### Visual Basic (VB)
####### What is VB?
####### VB Features
####### Advantages of VB
####### Difference between VB and VB
####### VB OPERATORS
####### OPERATORS
####### Arithmetic Operators
####### Comparison operators
####### Logical operators
####### Concatenation operators
####### Data Types
####### VB - Statements
####### VB Control Statements
####### Loops
####### Loop Control Statements
####### Arrays
####### Structures
####### Val Function
####### Basic Principles of Object Oriented Programming
####### Terminology
####### 4 major principles that make an language Object Oriented
####### Encapsulation
####### Abstraction
####### Inheritance
####### Polymorphism
####### Compile-time polymorphism (Overloading)
####### Runtime Polymorphism (Overriding)
####### Access Modifiers
####### Public
####### Private
####### Protected
####### Friend
####### Interface
####### Abstract Class
####### Unit 2
####### VB Form Control
####### Form Properties
####### Form Events
####### Form Methods
####### Setting the title Bar Text
TitleBarTextControl = "Control1";
####### Minimizing and Maximizing a form
####### Setting initial position of a form
####### StartPosition
####### Working with multiple forms
####### VB Controls
Object. Property = Value
####### Creating a message box
####### Creating a Input box
####### Creating MDI Applications
####### Creating Dialog box
####### Commenting the code
####### Label
####### Properties of the Label Control
####### Events of the Label Control
####### TextBox
####### The Properties of the TextBox Control
####### Events of the TextBox Control
####### Button
####### Properties of the Button Control
####### Events of the Button Control
####### ComboBox
####### Properties of the ComboBox Control
####### Events of the ComboBox Control
####### ListBox
####### Properties of the ListBox Control
####### UNIT 3
####### ProgressBar Control
####### Properties of the ProgressBar Control
####### Methods of the ProgressBar Control
####### Events of the ProgressBar Control
####### Timer Control
####### Timer Control Properties
####### Events of Timer Control
####### Methods of Timer Control
####### Checkbox
####### Properties of the CheckBox Control
####### Events of the CheckBox Control
####### Methods of the CheckBox Control
####### Radio button
####### Properties of the RadioButton Control
####### Events of the RadioButton Control
####### Methods of the RadioButton Control
####### Group box controls
####### Properties
####### Panel
1. It is an object-oriented programming language that follows various oops concepts such as abstraction,
encapsulation, inheritance, and many more. It means that everything in VB programming will be treated as an
object.
2. This language is used to design user interfaces for window, mobile, and web-based applications.
3. It also supports the multithreading concept, in which you can do multiple tasks at the same time.
4. Automatic initialized a garbage collection.
5. VB is not case sensitive like other languages such as C++ and Java.
Advantages of VB
1. The VB executes a program in such a way that runs under CLR (Common Language Runtime), creating a
robust, stable, and secure application.
2. It uses drop and drag elements to create web forms in .NET applications.
3. A VB can automatically structure your code.
4. It is a pure object-oriented programming language based on objects and classes.
5. It uses a new concept of error handling in the Visual Basic .NET Framework. The new structure is the try, catch, and
finally method used to handle exceptions as a unit. In addition, it allows appropriate action to be taken at the place
where it encountered an error.
Difference between VB and VB
1. VB is the predecessor of VB and was not an
object-oriented language.
2. It is an Interpreter based language
3. It does not support the multithread concept.
4. Visual Basic uses the VB-Runtime environment.
5. It is not a type-safe language.
1. It is a modern, fully object-oriented language that
replaced VB6.
2. It is a compiled language
3. A Multithreaded application can be developed in
VB.
4. A VB uses the Common Language Runtime
(CLR) component of .Net Framework at runtime. It
has better features and design implementation as
compared to VB-Runtime.
5. It is a type-safe language.
VB OPERATORS
1. Arithmetic operators
2. Comparison operators
3. Logical operators
4. Concatenation operators
OPERATORS
1. Arithmetic operators are used to perform arithmetic calculations such as addition and subtraction.
2. Comparison operators are used to compare two or more values or expressions.
3. Logical operators are used to perform logical operations such as AND, OR, NOT on one or more expressions.
4. Concatenation operators are used to join two string values. & and + are the two concatenation operators available
in VB. The operator & is used to concatenate two strings and + is used to add two numbers and concatenate
two strings.
Arithmetic Operators
Comparison operators
Concatenation operators
Data Types
Data types refer to an extensive system used for declaring variables or functions of different types. The type of a
variable determines how much space it occupies in storage and how the bit pattern stored is interpreted.
VB - Statements
A loop statement allows us to execute a statement or group of statements multiple times
1. Do Loop
It repeats the enclosed block of statements while a Boolean condition is True or until the condition becomes True. It
could be terminated at any time with the Exit Do statement.
Module loops Sub Main() ' local variable definition Dim a As Integer = 10 'do loop execution Do Console("value of a: {0}", a) a = a + 1 Loop While (a < 20) Console() End Sub End Module
2. For Next
It repeats a group of statements a specified number of times and a loop index counts the number of loop iterations
as the loop executes.
Module loops Sub Main() Dim a As Byte ' for loop execution For a = 10 To 20 Console("value of a: {0}", a) Next Console() End Sub End Module
3. For Each Next
It repeats a group of statements for each element in a collection. This loop is used for accessing and manipulating
all elements in an array or a VB collection.
Module loops Sub Main() Dim anArray() As Integer = {1, 3, 5, 7, 9} Dim arrayItem As Integer 'displaying the values
For Each arrayItem In anArray Console(arrayItem) Next Console() End Sub End Module
4. While End While
It executes a series of statements as long as a given condition is True.
Module loops Sub Main() Dim a As Integer = 10 ' while loop execution '
While a < 20 Console("value of a: {0}", a) a = a + 1 End While Console() End Sub End Module
5. Nested Loops
You can use one or more loops inside any another While, For or Do loop.
Module loops Sub Main() ' local variable definition Dim i, j As Integer For i = 2 To 100 For j = 2 To i ' if factor found, not prime If ((i Mod j) = 0) Then Exit For End If Next j If (j > (i \ j)) Then Console("{0} is prime", i) End If Next i Console() End Sub End Module
Loop Control Statements
1. Exit Statement
Terminates the loop or select case statement and transfers execution to the statement immediately following the
loop or select case.
Module loops Sub Main() ' local variable definition Dim a As Integer = 10 ' while loop execution '
While (a < 20) Console("value of a: {0}", a) a = a + 1 If (a > 15) Then 'terminate the loop using exit statement Exit While End If End While Console() End Sub End Module
2. Continue Statement
Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.
Module loops Sub Main() ' local variable definition Dim a As Integer = 10 Do
For i = 0 To marks - 1 Console(" Marks {0}", marks(i)) Sum = Sum + marks(i) Next Console(" Grand total is {0}", Sum)
Console(" Press any key to exit...") Console() End Sub End Module
Structures
In visual basic, Structures are same as classes but the only difference is classes are the reference types and
structures are the value types. As a value type, the structures directly contain their value so their object or instance will
be stored on the stack and structures are faster than classes.
In visual basic, the structures can contain fields, properties, member functions, operators, constructors, events,
indexers, constants and even other structure types.
Structure Simple Public _position As Integer Public _exists As Boolean Public _lastValue As Double End Structure
Module Module Sub Main() Dim s As Simple s._position = 1 s._exists = False s._lastValue = 5.
Console(s._position) End Sub End Module
Val Function
Returns the numbers contained in a string as a numeric value of appropriate type.
The Val function stops reading the string at the first character it can't recognize as part of a number.
Dim MyValue MyValue = Val("2457") ' Returns 2457. MyValue = Val(" 2 45 7") ' Returns 2457. MyValue = Val("24 and 57") ' Returns 24. MyValue = Val(" 1615 198th Street N.") 'Returns 1615198
Basic Principles of Object Oriented Programming
Object-oriented programming aims to implement real-world entities like inheritance, data hiding, polymorphism etc. in
programming.
The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the
code can access this data except that function.
Terminology
Class
A class is a user defined blueprint or prototype from which objects are created.
Objects
Objects are the instances of a class
4 major principles that make an language Object Oriented
Polymorphism
Polymorphism allows us to perform a single action in different ways. It refers to the ability of OOPs programming
languages to differentiate between entities with the same name efficiently.
Compile-time polymorphism (Overloading)
Imports System Module Module Public Class demo Public Overloads Function add(ByVal a As Integer, ByVal b As Integer) WriteLine("You are in function add(integer, integer)") Return a + b End Function Public Overloads Function add(ByVal a As Long, ByVal b As Long) WriteLine("You are in function add(long, long)") Return a + b End Function End Class Sub Main() Dim obj As New demo WriteLine(obj(2147483640, 4)) WriteLine(obj(2147483648, 1)) WriteLine("press return to exit...") Read() End Sub End Module
Runtime Polymorphism (Overriding)
Public Class Users
Public Overridable Sub GetInfo()
Console("Base Class")
End Sub
End Class
'Derived Class
Public Class Details
Inherits Users
Public Overrides Sub GetInfo()
Console("Derived Class")
End Sub
End Class
Access Modifiers
In visual basic, Access Modifiers are the keywords and those are useful to define an accessibility level for all the types
and type members.
Public
It is used to specifies that access is not restricted.
Private
It is used to specifies that access is limited to the containing type.
Protected
Creating a abstract class
we use MustInherit keyword to create abstract class. Abstract classes can also specify abstract members. Like
abstract classes, abstract members also provide no details regarding their implementation. Only the member type,
access level, required parameters and return type are specified. and to declare the abstract member we use
the MustOverride keyword.
Imports System
Imports System
Module Module
Public MustInherit Class Abstractclass
Public MustOverride Function square() As Integer
Public MustOverride Function cube() As Integer
End Class
Public Class AbstractFirst
Inherits AbstractClass
Dim A As Integer = 4
Dim B As Integer = 5
Public Overrides Function square() As Integer
Return A * A
End Function
Public Overrides Function cube() As Integer
Return B * B * B
End Function
End Class
Sub Main()
Dim abs1 As New AbstractFirst()
WriteLine("square of A is :" & " " & abs1())
WriteLine("Cube of B is :" & " " & abs1())
Read()
End Sub
End Module
Unit 2
VB Form Control
A Form is used in VB to create a form-based or window-based application. Using the form, we can build an
attractive user interface. It is like a container for holding different controls that allows the user to interact with an
application. The controls are an object in a form such as buttons, Textboxes, TextArea, labels, etc. to perform some
action.
Form Properties
BackColor
Sets the form background color.
BorderStyle
The BorderStyle property determines the style of the form's border and the appearance of the form
Font
This property specify font type, style, size
MinimizeBox
By default, this property is True and you can set it to False to hide the Minimize button on the title bar.
MaximizeBox
By default, this property is True and you can set it to False to hide the Maximize button on the title bar.
Form Events
Click
Occurs when the form is clicked.
DoubleClick
Occurs when the form control is double-clicked.
Closed
Occurs before the form is closed.
GotFocus
Occurs when the form control receives focus.
Load
Occurs before a form is displayed for the first time.
Form Methods
Activate
Activates the form and gives it focus.
ActivateMdiChild
Activates the MDI child of a form.
Close
Closes the form.
Show
Displays the control to the user.
ShowDialog
Shows the form as a modal dialog box.
Visual Basic .NET III SEM NOTES Complete 5 units
Course: Computer Science (Core 11)
University: Kristu Jayanti College
- Discover more from: