You are on page 1of 133

Visual Basic .

net

Mr. Jose Marie M. Pacia

VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS”

Visual Studio .net

• Microsoft’s Integrated Development Environment (IDE) for
creating running and debugging programs (called applications)
written in variety of programming languages

VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS”

Why move from VB6 to .Net?

• World of applications is changing
• Has a number of unique features

VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS”

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Overview of Visual Studio .net • Start Page – contains list of helpful links • There are two buttons on the page: – Open Project – New Project • To create a new project click new project VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Open Existing Project Create New Project VB .

Up close… • Variety of languages – Visual Basic Projects – Visual C# Projects – Visual C++ Projects – Setup and Deployment Projects – Visual Studio Solutions VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

– Include customized software that programmers create. IE6 ect. VB . Visual Basic Projects • Windows application – a program that executes inside a windows OS.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . example Microsoft Word.

Create Applications Project Name VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Project Name Path VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Console Programming • Console application – applications contain only text output • Visual Basic console applications consist of pieces called module VB .

Changing the default Module • Click on Project > Console Properties • On the startup object change the startup object to your startup module VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

To run a program

• On the menu bar press Debug
• Click start without debugging (F5 for shortcut key)

VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS”

Console Programming

• Printing a text
– Consolse.Write(“String”)
– Console.WriteLine(“The text goes here!”)
• Writeline position the text in the beginning of the next line

VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS”

Example 1

• VB.net\LaboratoryExercise\PrintingText

VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS”

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Variables • Stores data or information during program execution • How to declare – Dim variable_Name as Data_Type – To insert a value: • Dim variable_Name as Data_Type = Value VB .

VB . Note • Before VB can use an object variable. if any. it must determine its type and perform the necessary conversions.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Data Types • Types of Variables – Numeric – Store Numbers VB .

VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

+ • Subtraction .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” ./ • Division (Integer) \ • Modulus .Mod • Exponentiation .^ VB . Arithmetic Operators • Addition .- • Multiplication .* • Division .

Example 2 • \VB.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .net\LaboratoryExercise\ConsoleCalculator\ConsoleCalC VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . – Dim string_varialble as string – Dim string_varialble as string = “Value” VB . In the latter case. Character Variables • You can initialize a character variable by assigning either a character or a string to it. only the first character of the string is assigned to the variable.

Concatenation • Joining of two or more strings • Example • Dim string1 as string = “a” • Dim string 2 as string = “b” – String1 & string2 • ab VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Example 3 • VB.net\LaboratoryExercise\StringManipulation\StringManipulation VB .

Greater Than Equal • <= . Equality Operators • = .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .Equals • <> .Less than equal VB .Less Than • >= .Not Equal • > .Greater Than • < .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . If then If studentGrade>=60 then Console.WriteLine(“Passed”) End If VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Decision Making • If/then – Allows a program to make a decision based on the truth or falsity of some expression – It is a condition VB .

WriteLine("Enter first number: ") num1 = Console. Module Condition Sub Main() Dim lagyu As String Dim num1 As Integer Dim num2 As Integer Console.WriteLine("Number 2 is greater than number 3") End If End Sub End Module VB .ReadLine() If num1 > num2 Then Console.ReadLine() Console.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .WriteLine("Number 1 is greater than number 2") Else Console.WriteLine("Enter second number: ") num2 = Console.

WriteLine("Number are equal!") End If VB .WriteLine("Number 1 is greater than number 2!") Else Console.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . If else/ elseif / else If num1 > num2 Then Console.WriteLine("Number 1 is greater than number 2!") ElseIf (num2 > num1) Then Console.

Example 4 • VB.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .net\LaboratoryExercise\IFCondition\ifCondition VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . While Repetition Structure • A repetition structure allows the programmer to specify that an action should be repeated depending on the value of the condition VB .

WriteLine(ctr) End While End Sub End Module VB . Do while/Loop Module WhileLoop Dim ctr As Integer Sub Main() ctr = 1 While ctr <= 10 ctr = ctr + 1 Console.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

Do Until/Loop Repetition • Test a condition for falsity for repetition to continue. Statements in the body of a are executed repeatedly as long as the loop- continuation test evaluates to false VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

Module DoWhileLoop Dim ctr As Integer Sub Main() ctr = 10 Do Until ctr < 1 Console.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .WriteLine(ctr) ctr = ctr .1 Loop End Sub End Module VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Assignment Operators += C=+7 C = c +7 -= C-=7 C=c-7 *= C*=7 C=c*7 /= c/=7 C = c /7 \= c\=7 C=c\7 ^= C^=7 C=c^7 &= D &= “llo” D= D & “llo” VB .

WriteLine("The sum is " & sum) End Sub End Module VB . Module Module1 Sub Main() Dim a As Integer Dim var1 As Integer Dim sum As Integer a=1 sum = 0 While a <= 10 Console.WriteLine("Enter Number " & a & ":") var1 = Console.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .ReadLine() a += 1 sum = var1 + sum End While Console.

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . For/Next Repetition • Repetition structure handles the details of counter-controlled repetition. VB .

Module ForLoop

Sub Main()
Dim counter As Integer

For counter = 1 To 10
Console.WriteLine(counter)
Next
End Sub

End Module
VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS”

Using Dialog to Display Message

• On the solution explorer, right click on the reference and add
System.windows.forms

VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS”

Message box

• MessageBox.Show("Text", "Title Bar caption",
MessageBoxButtons.OK, MessageBoxIcon.Hand,
MessageBoxDefaultButton.Button1,
MessageBoxOptions.RightAlign)

VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS”

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Work Space • Form – Gray rectangle which represents the Windows Applications that the programmer is creating • The form which is the visual part of the program which the user interact VB .

Introduction to Windows Application Program • Messagebox Title Bar Text MesageboxIcon.I Message Text nformation MessageBox.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .OK VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .Exclamation – Excalmation Point • MessageBoxIcon.Error – Icon containing the red x circle VB . • MessageBoxIcon.Question – Icon Containing question mark • MessageBoxIcon.Information – Icon Containing the letter I • MessageBoxIcon.

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .RetryCancel – Retry and Cancel Button VB .OKCancel – OK and Cancel buttons • MessageBoxButtons.OK – OK button • MessageBoxButtons. • MessageBoxButtons.YesNo – Yes and No Buttons • MessageBoxButtons. no and cancel buttons • MessageBoxButtons.YesNoCancel – Yes.

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Select Case Multiple-Selection Structure Select Case variable Case <decision 1> Code Case <decision 2> Code Case Else Code End Select VB .

WriteLine("Default") End Select End Sub End Module VB .WriteLine(1) Case 2 Console. Module SelectCaseModule Sub Main() Dim choys As Integer Console.ReadLine Select Case choys Case 1 Console.WriteLine("Enter Choice") choys = Console.WriteLine(2) Case Else Console.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

Exit For statements alter the flow of control by causing immediate exit from a repetition structure VB . Exit Keyword in a Repetition • Exit Do.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Exit While.

• Exit Do – Exit a do while repetition • Exit for – Exit a for loop • Exit While – Exit a while repetition VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

Logical Operators • Visual Basic provides logical operators that can be used to form complex conditions by combining simple ones VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . • AndAlso • And • OrElse • Or • Xor • Not VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . AndAlso • False + False = False • False + True = False • True + False = False • True + True = True VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . OrElse • False + False = False • False + True = True • True + False = True • True + True = True VB .

Not • True = False • True = False VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Xor • False + False = False • False + True = True • True + False = True • True + True = False VB .

WriteLine("Enter Choice") choys = Console.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .WriteLine(name) End Sub End Module VB .ReadLine Select Case choys Case 1 proc1("jpacs") End Select End Sub Sub proc1(ByVal name As String) Console. Sub Procedures Module SubProc Sub Main() Dim choys As Integer Console.

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Procedure • Similar to sub procedure except that function procedures return a value Function procedure-name(parameter list) as return type Declarations and Statement End Function VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . val2) VB .Max(val1. Maximum • Get the maximum value of two number – Math.

Windows.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . val3) End Sub End Class VB . val3 As Double Private Sub cmdMax_Click(ByVal sender As System.Text val2 = txtSecond.Form Dim val1.Max(Math.Text val3 = txtThird.EventArgs) Handles cmdMax. Public Class frmMax Inherits System.Click val1 = txtFirst. val2).Object. val2.Text lblTotal.Max(val1.Forms.Text = Math. ByVal e As System.

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . More Math Functions • Abs(x) – returns absolute value of x • Ceiling(x) – rounds x to the smallest integer • Cos(x) returns the trigonometric cosine VB .

• Exp(x) – returns the exponential ex • Floor(x) – rounds x to the largest integer not greater than x • Log(x) – returns the natural logarithm of x (base e) • Max(x.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .y) – returns the larger value of x and y • Min(x.y) – returns the smallest value of x and y VB .

• Pow(x,y) – Calculates x reaised to power y(xy)
• Sin(x) – returns the trigonometric sine of x(x in radians)
• Sqrt(x) – returns the square root of x
• Tan(x) – returns the trigonometric tangent of x (x in radians)

VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS”

• Random
– Dim randomObject as Random = New Random()
– Dim randomNumber as Integer = randomObject.Next()

VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS”

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim randomObject As Random = New Random
Dim randomNumber As Integer

randomNumber = randomObject.Next(1, 10)
lblRandom.Text = randomNumber
End Sub

VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS”

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Modules • Programmers use modules to group related procedures so that they can be reused in other projects VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . How to add modules • Goto File > Add new item • On the template select module VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Module Module1 Function reuse(ByVal lbl As Label) lbl.Text = "jpacs" End Function End Module VB .

ToChar(1) VB .ToString (val2) – Convert. Convert • Use to convert variables or value on a desired data type • Example – Convert.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Array • Can store information and has indexes or memory address • Array have the same name and same type • The first element of an array is 0th Element • The position on the array is called index VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Public Class Form1 Inherits System.Forms.Windows.Form Dim numarray(10) As Integer Private Sub Form1_Load(ByVal sender As System.Object.Text = numarray(0) End Sub End Class VB .Load numarray(0) = 1 Label1. ByVal e As System.EventArgs) Handles MyBase.

GUI • Label – An area in which icons or un editable text is displayed • Textbox – An area in which the user inputs data from the keyboard.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . This can also display information • Button – An area that triggers an event when clicked • CheckBox – A component that is either selected on unselected VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Multiple elements can be selected. VB . • ComboBox – A drop-down list of items from which the user can make a selection either by clicking an item in the list or by typing into a box • ListBox – An area in which a list of items is displayed. The user can make a selection from the list by clicking on any item.

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . • Panel – A container in which components can be placed • Scrollbar – A component that allows the user to access a range of elements that normally cannot fit in the control’s container VB .

select the component on the toolbox and drag it on the form VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Toolbox • Contains all the windows forms and components • To add a component on a form.

VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .exit VB . Unload a form • Application.

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . single.. 3d) VB . none. Form Properties and Events • AcceptButton – Button that is clicked when Enter is pressed • AutoScroll – Boolean value that allows or disallows scrollbars to appear when needed • CancelButton – Button that is clicked when the Escape key is pressed • FormBorderStyle – Border style for the form (e.g.

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . and the default font of controls added to the form • Text – Text in the form’s title bar VB . • Font – font of text displayed on the form.

A closed form cannot be open.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . • Hide – Hides form • Show – Display hidden forms VB . Common Methods • Close – Closes a form and releases all resources.

Code • formName.Close() VB .ActiveForm.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

Text = txtLastName.Text VB .Text = txtEmpNo.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .Text & " " & txtFirstName.Text – txtEmpNameOut. Textbox • Passing a value: – txtEmpNoOut.

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .05 • txtTax.Text = Val(txtSalaryMain. Mathematical Operator on Text Box • txtPhilhealth.Text) * 0.03 VB .Text) * 0.04 • txtSSS.Text) * 0.Text = Val(txtSalaryMain.Text = Val(txtSalaryMain.

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .Items. Combo Box • Adding Items on runtime – ComboBox1.Add("ABC") • Clearing Items on runtime – ComboBox1.Clear() VB .Items.

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .use to insert all the choices on your combo box VB . Dropdown. Simple • Items . Properties of a combo box • DropDownStyle – Dropdownlist.

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .Add("ABC") Clearing the items on the combo box • cmbChoice.Clear() VB . Adding Items on Combo on runtime • cmbChoice.Items.Items.

Items. Getting the items on a combo • cmbChoice.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .Item (index number) VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Radio Button • Allows a user to choose a options • Properties – Check = combo box is selected (True = Selected. False = Un Selected) – Text = Text displayed on option Button VB .

Example GUI 1 • Calculator • Payroll System VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

JPEG. The image. VB . set by an object of class Image. icon or metafile format.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Picture Boxes • A picture box displays an image. can be a bitmap. a GIF.

AutoSize and Center Image) VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . StretchImage. Picture Box Properties • Image – sets the image to display in the Picture Box • SizeMode – Enumeration that controls image sizing and positioning.

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . • Normal places the image in top-left corner of picture box • CenterImage puts the image in middle (both truncate image if it is too large) • StretchImage resizes image to fit in PictureBox. • AutoSize resizes PictureBox to hold image VB .

FromFile("D:\VB.jpg") VB . Loading Picture on Runtime • picOne.net\LaboratoryExercise\Picture Swapper\Pictures\Pic2.Image = Image.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

GetCurrentDirectory) VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .fromfile (directory. Selecting the Current directory or Path • .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Example GUI 2 • Picture Swapper VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . List Box • Allows the user to view and select from multiple items in a list VB .

List Box Properties • Items – Collection of an item in a listbox • SelectedIndex – Returns the index of the selected item. the property returns arbitrary returns one of the selected indeces. If no items are selected.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . If selected multiple items. the property returns to -1 VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . • SelectedIndeces – Returns a collection containing the indeces for all selected items • SelectedItem – Returns a reference to the selected item (If multiple items are selected. it returns the items with the lowest number of index) • SelectedItems – Returns a collection of selected items VB .

• SelectionMode – Determines the number of items that can be selected – Values(None. One.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Multiple) • Sorted – Indicates whether items are sorted alphabetically VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Adding of Item • listOrder.Add(“Item to Add”) VB .Items.

Removing of items • listOrder.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .Items.Count VB .Items.Clear() • Counting of items on a list – listOrder.

CheckedListBoxes • Control derives from Listbox but contains checkbox before each item VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

One(Multiple) and None(Does not allow) VB . Properties • CheckedItems – Contains the collection of items that are checked • CheckedIndeces – Returns all indexes for checked items • SelectionMode – Determines how many items can be checked.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .GetItemChecked(ctr .1) End If VB .RemoveAt(ctr .Items. To get checked item tmp = listOrder.1) If tmp = True Then listOrder.

Items.1) VB .RemoveAt(ctr .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Remove item • listOrder.

Example GUI 3 • Font Browser • POS VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Creating Shapes • Import System.Drawing on your program VB .

CreateGraphics Dim mypen As New Pen(Color.DrawEllipse(mypen.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . 100.Drawing Public Class frmShapes Dim mygraphics As Graphics = MyBase. Imports System.DarkRed) Private Sub cmbShapes_SelectedIndexChanged_1(ByVal sender As System.Object. 10) End If End Sub End Class VB .Text = "Ellipse" Then mygraphics.Clear(Color.SelectedIndexChanged If cmbShapes. 100. 100.EventArgs) Handles cmbShapes. ByVal e As System.White) mygraphics.

width) VB . x. height.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .DrawEllipse(color of pen. y. Ellipse • mygraphics.

• Nodes are objects that contain values and can refer to other nodes • Parent node can contain child nodes • A child node can be a parent node to other nodes VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Tree View • Displays nodes hierarchically in a tree.

• First node on the tree is the root node • Two child nodes are called siblings node VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

Properties of Tree View • Checkboxes – Indicates whether a checkboxes appear next to node • ImageList – Specifies ImageList containing the node icon • Nodes – List the collection of TreeNode. in the control VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

Node • Add (Adds a tree node object) • Clear (Clears the entire collection of tree node) • Remove (Delete a specific node) VB . Methods on Treeview.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

ByVal e As System.Text = "ACT" Then treeStudents. " + txtFName.Text + " " + txtMI.Click Dim StudName As String StudName = txtLName.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .EventArgs) Handles btnAdd.Text If cmbCourse.Add(StudName) End If End Sub End Class VB .Object. Code Public Class frmTree Private Sub btnAdd_Click(ByVal sender As System.Nodes(0).Nodes(0).Nodes.Text + ".

Size.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .Font Style) VB . Font Properties • New Font(Font.

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .Pixel) VB . 14.Italic. FontStyle. GraphicsUnit.Font = New Font("Comic Sans Serif". Code • Label1.

When a checkbox is selected. VB . Checked box • Small white square that either is blank or contains a checkmark.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . a blank checkmark appears in the box.

Properties of a checkbox • Checked – Indicates whether the checkbox is checked or marked • CheckState – Indicates whether the checkbox is checked or unchecked • Text – Specifies the text displayed to the right of the Checkbox called label VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .Font = New Font(cmbFonts.Checked Then txtOutput.Font = New Font(cmbFonts.Regular) End If VB . 12. 12. Code If chkBold.Text. FontStyle. FontStyle.Text.Bold) Else txtOutput.CheckState = CheckState.

Common Dialog Box • A rather tedious. font names and sizes. task in nearly every application is to prompt the user for filenames. but quite common.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . or colors to be used by the application VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . OpenFileDialog • OpenFileDialog Lets users select a file to open. VB . for applications that must process many files at once (change the format of the selected files. for example). It also allows the selection of multiple files.

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Files and Streams • Create Directory contains information about a directory – AppendText – Returns a StreamWriter that appends to an existing file or creates a file if one does not exist VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .net • Ado. Database Programming using ADO.NET framework and is the next generation of ActiveX Data Objects (ADO). • Was created for the .net object model provides an API for accessing database systems programmatically. which was designed to interact with Microsoft’s Components Object Model (COM) framework VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .net • simplify the code you write • allow you to bind graphical controls to DataSets VB . ADO.

Primary Library of ADO.data.Dataset VB .data • System.net • System.Data.SqlClient • System.Data.OleDb • System.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Data Set • uses the DataSet to store disconnected data VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Adding OledbAdapter • Click on Tools > Choose Toolbox Items • Click on .Net Framework Componets • Select OledbAdapter and Click OK VB .

NET • also includes a new type of connection: SQLConnection VB . oleDbConnection • The oleDbConnection object uses OLE DB to connect to a data source. ADO.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

Open() VB .” • Dim myConn As New oleDbConnection() • myConn.Data Source=localhost. • Dim connString As String = _ • “Provider= SQLOLEDB.pwd=.1.ConnectionString = connString • myConn.Initial Catalog=northwind.net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .” & _ • “uid=sa.

Example Database • Dbase Application VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

• The End!!!! VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

Data Adapter Wizard • New Connection – Data Source – Database Connection – Database File Name – File Name of the database • Change the Datasource – Microsoft Access Database File – Click Ok – Find the Access File – Test the connection VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . Continuation • Click OK • Choose Use SQL Statements • Insert your SQL • Click Finish VB .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . More… • You will be returned at the design tab • There are two components that has been added: – oleDbDataAdapter1 – oleDbConnection1 VB .

NET. • The oleDbDataAdapter1 control describes your actual query • In VB. the object you use to store data is called a DataSet. • The oleDbConnection1 control describes the database connection. VB .net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” .

net © COPYRIGHT BY BADBOY INC PRESENTED BY:SIR “JPACS” . a new menu item has appeared: DataSet • Drag the DataSet on the form • Select untype data sets VB . • Notice that on the menu bar. Data Set • Click once on the form.