SlideShare a Scribd company logo
.NET Technology
By
Akber Ahmed Khowaja
Today’s Discussion
 What We Expect From Language?
 What is new in .NET?
 Comparisons with Previous Technologies /
JAVA / VB-6 etc.
 First Look of VB .NET
What is in Language?
 Interaction With Other Language
 Platform Support
 Programming Technique (structured ? Procedural? OOP?)
 Databases Support
 Database Handling Technique
 Thread Model
 Component Designing?
 Network Support Programming? (Socket Programming)
 Internet Programming ?
 Future / Reliability?
What is new in .NET Technology
.NET Framework covers all the layers of software
development from the operating system up
.NET Framework
ASP.NET
Web Services Web Forms
ASP.NET Application Service
Windows Forms
Controls Drawing
Windows Application Service
.NET Framework Base Classes
ADO.NET XML Threading IO
Net Security Diagnoses Etc.
Common Language Runtime
Memory
Management
Common Type System
Lifecycle
Monitoring
Windows Forms (Winforms)
Windows Form are a new way to create Standard WIN32
Desktop Application based on the Windows Foundation
Classes(WFC)
Web Forms
Web Forms provide a powerful, form based user interface for
web, it also contains additional .net ASP controls which was
not present in previous versions, These controls provide
Sever based events facility so that our application can be
develop more easily and attractive.
Web Services
Provides a mechanism for programs to communicate over
the Internet using SOAP (Simple Object Access Protocol).
Web Services provide an analog of Com and DCOM for
object brokering and interfacing, but based on internet
technologies so that allowance is made for integration,
even with non Microsoft plateforms
CLR (Common Language Runtime)
Common Type System
Data Types / etc
Intermediate Language to
Native Code Compiler
Execution Support Security
Garbage Collection
Memory Management(Previous version it was done by OS)
Multiple Language Support
.Net Environment Provides Multiple language Integration
Support, se that we can use multiple Languages in single
program.
For Example we can C# function in ASP.NET as well as in
VB.NET
Cross language Inheritance is also Possible
So Mix Language development team can also participate to
develop program.
How IT is Possible ? Answer CLR
Common Type System
All Languages use same Data types, their Length, Size, Type
and specificaton will be same.
For example in Previous VB-6 use 16 bit Integer (2 bytes)
In Visual C integer was 4 Bytes.
Now For all .NET Support languages use int32 Integer for 4
Bytes.
Common Types
Boolean Sbyte (Signed Byte)
Byte Single
Char
Date/Time
Decimal
Double
Int16
Int32
Int46
Execution Support
JIT (Just in Time Compilation and Execution)
JIT Compiles with three methods:
1) Standard JIT: it Convert to exe code at the time of
execution
2) Pre JIT: it it convert to exe code at the time of
installation.
3) Econo JIT: it create low Optimization code, for low
memory resources
Programming Technique
OOP (Object Oriented Programming)
a) Encapsulation
b) Inheritance
c) Polymorphism
Form Level Inheritance
1 2
1 2
3 4
Form 1 Form2 inherited from
Form1
Database Handling
It use ADO+ or ADO.NET To handle different Databases
Disconnected Databases
SQL
OLEDB Drivers
(Will be discuss in Detail)
XML Support
 It Gives XML support to represent Fast Data
VB.NET Programming
By:
Akber Ahmed Khowaja
Today’s Discussion
 VS.NET (Visual Studio.net Environment)
 Working With WinForms & important
Properties
 Working With Events in .NET
 Data Base Creation with MS-SQL Server
 Database Handling with VS.NET
VS.NET Environment
Form Properties
Database Handling With ADO.NET
 Import System.Data
 Import System.data.ADO
 Create and set SQLConnection
 Create and set SQL DataAdapter
 Create and set Dataset
Steps to Create & Set
SqlConnection
1. Place SqlConnection To Form (from Data
toolBox)
2. Set its name property to con1
3. Set its Connection Property using connection
Wizard
Steps to Create & Set DataAdapter
1. Put DataAdapter Control to form
2. Right click on That Control
3. Select Configure
4. Follow Steps to complete Process
5. Right Click on DataAdapter Control, and
select Create DATASET
Put Following Code on Form’s Load
Event
Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
da1.Fill(ds1, "ghufi")
End Sub
Form Design Layout
Private Sub cmdLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles cmdLast.Click
cnt = Me.ds1.Tables("ghufi").Rows.Count
Me.BindingContext(ds1, "ghufi").Position = Me.BindingContext(ds1, "ghufi").Count - 1
MsgBox(cnt.ToString)
End Sub
Private Sub cmdNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdNext.Click
Me.BindingContext(ds1, "ghufi").Position = Me.BindingContext(ds1, "ghufi").Position
+ 1
End Sub
Private Sub cmdPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles cmdPrev.Click
Me.BindingContext(ds1, "ghufi").Position = Me.BindingContext(ds1, "ghufi").Position -
1
End Sub
Private Sub cmdFirst_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdFirst.Click
Me.BindingContext(ds1, "ghufi").Position = 0
End Sub
Todays Discussion
 Few Language Tips
 How To search
 Working wit DataGrid
 Add Records
 Save Records
Few Language Changes
 Data Types
 Declaration Methods
 Type Casting
 Option keyword
 Changes in Array
Data Types (Integers)
 Byte 8 Bits 0 to 255
 Short
 Integer
 Long
Floats
 Single
 Double
 Decimal 128 bits
Others
 Char
 String
 Varient  Object
Declaration of Variables
 Dim I , j , k as integer
Option
 Option Explicit On/Off
 Option Compare Binary/Text
 Option Strict On/Off (Data type conversion)
Find Records
On Load
txtfind.Text = ds1.ghufi.Columns.Count()
ComboBox1.Items.Add(ds1.ghufi.Columns(0).ColumnName)
ComboBox1.Items.Add(ds1.ghufi.Columns(1).ColumnName)
ComboBox1.Items.Add(ds1.ghufi.Columns(2).ColumnName)
ComboBox1.Items.Add(ds1.ghufi.Columns(3).ColumnName)
Write Following Code under Find
Dim fldname As String
fldname = ComboBox1.SelectedItem()
ds1.Clear()
da1.SelectCommand.CommandText =
"select * from ghufi where " & fldname & "='" & txtfind.Text & "'“
da1.Fill(ds1, "ghufi")
If Me.BindingContext(ds1, "ghufi").Count <= 0 Then
MsgBox("Sorry No Record for your Search")
End If
Today’s Discussion (03/11/2002)
 New Control “Notify Icon”
 How to Navigate B/W Forms
 Inheritance in Forms
 How User Master Details
 Add / Save
NotifyIcon Control
Notify Icon is a new control which put a link on System
Tray, it automatically creates a new panel in system tray and
shows Icon.
It’s Click Event Fires when we double click on that Icon.
We may use it for new form load, or terminate Application.
Steps to use NotifyTray
 Drag and drop this control on Form
 Set it’s Icon Property with any suitable Icon
 Write “End” to its click event
Form Level Inheritance
Put Form1 as Following
Insert Another Form
Its coding is
Public Class Form4
Inherits System.Windows.Forms.Form
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles
MyBase.Load
End Sub
End Class
Change this coding as
Public Class Form4
Inherits System.amin.form3
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles
MyBase.Load
End Sub
End Class
Set form4 as Default For and Run Program
Come back to Database
Master Details Forms
Database Structure
Put Sample Data
Form Structure
ListBox Properties, Datagrid Prop.
Code on ListIndexChanged
ds2.Clear()
da2.SelectCommand.CommandText = "select * from ghufi_details
where id=" &
CInt(sender.Text)
da2.Fill(ds2, "ghufi_details")
output
VB.Net Programming
By
Akber Ahmed Khowaja
DialogBox
 FileDialogBox
 SaveDialogBox
 FontDialogBox
 ColorDialogBox
 PrintDialogBox
Screen For Dialog Boxes
Open
Save
Font
Color
Print
Today’s Discussion (18/11/2002)
 Add New Record with Programming
 Edit Record
 Delete Record
OpenFileDialogBox
Imports System.IO
openDialog.Filter = "Text Files (*.txt)|*.txt|All Files|*.*“
openDialog.FilterIndex = 1
openDialog.InitialDirectory = "c:“
openDialog.Title = "Demo Open Dialog“
openDialog.ShowDialog()
strfilename = openDialog.FileName
Dim objreader As StreamReader = New StreamReader(strfilename)
TextBox1.Text = objreader.ReadToEnd
objreader.Close()
objreader = Nothing
Do Until objreader.Read = -1
TextBox1.Text = TextBox1.Text &
objreader.ReadLine & vbCrLf
Loop
SaveDialog & FileStreamWriter
With saveDialog
.DefaultExt = "txt“
.FileName = strfilename
.Filter = "Text Files(*.txt)|*.txt|All Files|*.*“
.FilterIndex = 1
.InitialDirectory = "c:“
.OverwritePrompt = True
.Title = "File Save Demo“
End With
saveDialog.ShowDialog()
strfilename = saveDialog.FileName
Dim objwriter As StreamWriter = New
StreamWriter(strfilename, False)
objwriter.Write(TextBox1.Text)
objwriter.Close()
objwriter = Nothing
FontDialogBox
FontDialog.ShowColor = True
FontDialog.ShowDialog()
TextBox1.Font = FontDialog.Font
Color Dialog
colorDialog.ShowDialog()
TextBox1.ForeColor = FontDialog.Color
Print Dialog
PrintDialog.AllowPrintToFile = False
PrintDialog.AllowSelection = False
PrintDialog.AllowSomePages = False
PrintDialog.ShowDialog()
Menu Designing
Steps To Design Menu
 There are two Types of Menues
– Main Menu
– Context Menu
Main Menu
This Menu Appear Normally on the Top of the form, this is very
common menu for windows base applications.
ie. File, Edit, View etc
Context Menu
This menu is Small Menu Which appears when user right click
on Any Form Item
Steps To Design Main Menu
 Drag and drop main menu from Toolbox
 Write Menu Name
 Use & for Access Keys
 Set Properties of every menu
– Name
– Shortcut
Steps Context Menu
 Drag and drop Context menu from ToolBox
 Design some menu items
Every Control has Context menu property, we
bind context menu property to context menu,
so that menu will appear when user right click
on that menu
Screen Layout
Import
Imports System.Data
Imports System.Data.OleDb
Imports System.DBNull
Declarations
Public Class Form2
Inherits System.Windows.Forms.Form
Public con As OleDbConnection = New
OleDbConnection("Provider=Microsoft.jet.
oledb.4.0; data
source=d:LibrarySystemlibrary.mdb")
Public da As OleDbDataAdapter
Public ds As DataSet
Public dw As DataView
Public cm As CurrencyManager
Initializations (call two functions)
'Add any initialization after the
InitializeComponent() call
FillData()
bindFields()
FillData Function
Private Sub FillData()
dw = Nothing
ds = New DataSet()
con.Open()
da = New OleDbDataAdapter("select *
from books", con)
da.Fill(ds, "books")
dw = New DataView(ds.Tables("books"))
cm = CType(Me.BindingContext(dw),
CurrencyManager)
con.Close()
End Sub
DataBinding Function
Private Sub bindFields()
TextBox1.DataBindings.Clear()
TextBox2.DataBindings.Clear()
TextBox1.DataBindings.Add("text", dw, "code")
TextBox2.DataBindings.Add("text", dw, "Name")
End Sub
Add Button Code
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
Save Button
Dim pos As Integer
pos = cm.Position
Dim cmd As New OleDbCommand()
cmd.Connection = con
cmd.CommandText = "Insert into books (code,
name, author) values(?,?,?)“
cmd.CommandType = CommandType.Text
con.Open()
cmd.Parameters.Add(New OleDbParameter())
cmd.Parameters.Item(0).Direction = ParameterDirection.Input
cmd.Parameters.Item(0).DbType = DbType.String
cmd.Parameters.Item(0).Size = 10
cmd.Parameters.Item(0).Value = TextBox1.Text
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox("Error:=" & ex.Message)
End Try
con.Close()
FillData()
bindFields()
MsgBox("Record Added")
ds = Nothing
da = Nothing
cmd = Nothing
Edit
cmd.CommandText = "update books set
name=?,author=? where code=?"
cmd.CommandType = CommandType.Text
Delete
cmd.CommandText = “delete from books where code=?"
cmd.CommandType = CommandType.Text
Pos=1
Me.BindingContext(ds1, "ghufi").AddNew()
da1.Update(ds1, "ghufi")
da1.Fill(ds1, "ghufi")
Handling ADO With Coding
By
Akber Ahmed Khowaja
Code for Import Files
Imports System.Data
Imports System.Data.OleDb
Imports System.DBNull
Public Class Form2
. . . . .
. . . . .
Variable Declaration
• For Connection
• For Data Adapter
• For Dataset
Few Slides Are Remaining
Today’s Discussion (Dec 02, 2002)
 Concept Of OOP
 What is Class
 Simple Class
 Methods
 Constructors
 Properties
 Data Base Handling With Class
What is OOP
OOP is Programming technique in which we make programs
Flexible and Reusable.
Basic Concept of OOP is Designing Classes in Program.
What is Class
Class is Collection of Data / Properties and
Methods/Functions which operate on that data.
Methods and Data are Encapsulated in Class, is
called Encapsulation
We may Inherit functionality of one class to other class is
called Inheritance.
With class one object may work with different ways is
called Polymorphism
A Simple Class
Write Click On Project add Class to your project
Public Class Person
Public FName As String
Public LName As String
Public Age As Integer
End Class
Form for Usage of “Person” class
Create Object for “Person” Class
Dim p1 As New Person()
Code for Insert Data / Show Data
Buttons
p1.FName = TextBox1.Text
p1.LName = TextBox2.Text
p1.Age = CInt(TextBox3.Text)
TextBox1.Text = p1.FName
TextBox2.Text = p1.LName
TextBox3.Text = p1.Age
Encapsulation (Private Data and
Access public Methods)
Public Class Person
Private FName As String
Private LName As String
Private Age As Integer
'setdata Method
Public Sub setData(ByVal Fnm As String, ByVal LNm As
String, ByVal ag As Integer)
FName = Fnm
LName = LNm
Age = ag
End Sub
Public Function getFName() As String
Return (FName)
End Function
Public Function getLName() As String
Return (LName)
End Function
Public Function getAge() As Integer
Return (Age)
End Function
End Class
Constructor
Constructor is Special Type of method which call
automatically when object creates, we may use constructor
for data initialization.
Public Sub New()
FName = "FName Not Set"
LName = "LName Not Set"
Age = 0
End Sub
Array Of Objects
Dim p(10) As Person
Dim cntr As Integer
Screen For Use Array of Objects
Code for Set Data Button
p(cntr) = New Person()
p(cntr).setData(TextBox1.Text,
TextBox2.Text, CInt(TextBox3.Text))
MsgBox("Data Stored as index number : " & CStr(cntr))
cntr += 1
Code for Show Data Button
Dim xx As Integer
xx = txtIndex.text
TextBox1.Text = p(xx).getFName()
TextBox2.Text = p(xx).getLName()
TextBox3.Text = p(xx).getAge()
Properties For Class
Property FName() As String
Get
Return (XFName)
End Get
Set(ByVal Value As String)
XFName = Value
End Set
End Property
Use Properties
dim t1 as new Teacher() ‘ teacher is class
t1.FName = TextBox1.Text
t1.LName = TextBox2.Text
t1.Age = TextBox3.Text
Data base Handling with class
Public Class DataClass
Public con As OleDbConnection
Public da As OleDbDataAdapter
Public ds As DataSet
Public dw As DataView
Public cm As CurrencyManager
Method Open Connection
Public Sub openConnection(ByVal constr As String)
con = New OleDbConnection(constr)
con.Open()
End Sub
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’
Private Sub setDa(ByVal sqlstr As String, ByVal cn As
OleDbConnection)
da = New OleDbDataAdapter(sqlstr, cn)
End Sub
Public Sub FillData(ByVal sqlstr As String, ByVal dbnm As
String, ByVal tblnm As String)
dw = Nothing
ds = New DataSet()
OpenConnection("Provider=Microsoft.jet.oledb.4.0; data
source=f:Inventory_VBNETInventorySystem" & dbnm)
setDa(sqlstr, con)
da.Fill(ds, tblnm)
dw = New DataView(ds.Tables(tblnm))
con.Close()
End Sub
Move Records
Public Sub MoveRecord(ByVal bc As
BindingContext, ByVal tblnm As String,
ByVal symbol As String)
If symbol = ">" Then
bc(ds, tblnm).Position += 1
ElseIf symbol = "<" Then
bc(ds, tblnm).Position -= 1
ElseIf symbol = "<<" Then
bc(ds, tblnm).Position = 0
ElseIf symbol = ">>" Then
bc(ds, tblnm).Position = bc(ds, tblnm).Count – 1
End If
Usage
‘Create Object
Dim obj As New DataClass()
'Add any initialization after the
InitializeComponent() call
obj.FillData("select * from items", "Inventory.mdb",
"Items")
showData()
Private Sub showData()
Dim pos As Integer
pos = Me.BindingContext(obj.ds,
"items").Position
TextBox1.Text =
obj.ds.Tables("items").Rows(pos).Item("itemName")
End Sub
Show Data Method
Code For Next Button_Click
obj.MoveRecord(Me.BindingContext, "Items", ">")
showData()

More Related Content

What's hot

Filesinc 130512002619-phpapp01
Filesinc 130512002619-phpapp01Filesinc 130512002619-phpapp01
Filesinc 130512002619-phpapp01Rex Joe
 
file handling, dynamic memory allocation
file handling, dynamic memory allocationfile handling, dynamic memory allocation
file handling, dynamic memory allocationindra Kishor
 
basics of file handling
basics of file handlingbasics of file handling
basics of file handlingpinkpreet_kaur
 
C# 6 and 7 and Futures 20180607
C# 6 and 7 and Futures 20180607C# 6 and 7 and Futures 20180607
C# 6 and 7 and Futures 20180607Kevin Hazzard
 
File Handling In C++(OOPs))
File Handling In C++(OOPs))File Handling In C++(OOPs))
File Handling In C++(OOPs))Papu Kumar
 
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...Maulik Borsaniya
 
Data file handling
Data file handlingData file handling
Data file handlingTAlha MAlik
 
Data file handling in c++
Data file handling in c++Data file handling in c++
Data file handling in c++Vineeta Garg
 
Python File Handling | File Operations in Python | Learn python programming |...
Python File Handling | File Operations in Python | Learn python programming |...Python File Handling | File Operations in Python | Learn python programming |...
Python File Handling | File Operations in Python | Learn python programming |...Edureka!
 
C++ Windows Forms L11 - Inheritance
C++ Windows Forms L11 - Inheritance C++ Windows Forms L11 - Inheritance
C++ Windows Forms L11 - Inheritance Mohammad Shaker
 
Merge Multiple CSV in single data frame using R
Merge Multiple CSV in single data frame using RMerge Multiple CSV in single data frame using R
Merge Multiple CSV in single data frame using RYogesh Khandelwal
 

What's hot (20)

Filesinc 130512002619-phpapp01
Filesinc 130512002619-phpapp01Filesinc 130512002619-phpapp01
Filesinc 130512002619-phpapp01
 
File handling in c++
File handling in c++File handling in c++
File handling in c++
 
file handling, dynamic memory allocation
file handling, dynamic memory allocationfile handling, dynamic memory allocation
file handling, dynamic memory allocation
 
basics of file handling
basics of file handlingbasics of file handling
basics of file handling
 
C# 6 and 7 and Futures 20180607
C# 6 and 7 and Futures 20180607C# 6 and 7 and Futures 20180607
C# 6 and 7 and Futures 20180607
 
File Handling In C++(OOPs))
File Handling In C++(OOPs))File Handling In C++(OOPs))
File Handling In C++(OOPs))
 
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...PYTHON -Chapter 2 - Functions,   Exception, Modules  and    Files -MAULIK BOR...
PYTHON -Chapter 2 - Functions, Exception, Modules and Files -MAULIK BOR...
 
Data file handling
Data file handlingData file handling
Data file handling
 
File Handling in C++
File Handling in C++File Handling in C++
File Handling in C++
 
File handling in Python
File handling in PythonFile handling in Python
File handling in Python
 
Functions in python
Functions in pythonFunctions in python
Functions in python
 
Data file handling in c++
Data file handling in c++Data file handling in c++
Data file handling in c++
 
Session 4
Session 4Session 4
Session 4
 
Intake 37 linq2
Intake 37 linq2Intake 37 linq2
Intake 37 linq2
 
Python File Handling | File Operations in Python | Learn python programming |...
Python File Handling | File Operations in Python | Learn python programming |...Python File Handling | File Operations in Python | Learn python programming |...
Python File Handling | File Operations in Python | Learn python programming |...
 
C++ Windows Forms L11 - Inheritance
C++ Windows Forms L11 - Inheritance C++ Windows Forms L11 - Inheritance
C++ Windows Forms L11 - Inheritance
 
COM1407: File Processing
COM1407: File Processing COM1407: File Processing
COM1407: File Processing
 
Merge Multiple CSV in single data frame using R
Merge Multiple CSV in single data frame using RMerge Multiple CSV in single data frame using R
Merge Multiple CSV in single data frame using R
 
Python - Lecture 8
Python - Lecture 8Python - Lecture 8
Python - Lecture 8
 
Chapter10
Chapter10Chapter10
Chapter10
 

Similar to VB Dot net

Bt0082 visual basic
Bt0082 visual basicBt0082 visual basic
Bt0082 visual basicTechglyphs
 
Visual Studio.NET
Visual Studio.NETVisual Studio.NET
Visual Studio.NETsalonityagi
 
The Ring programming language version 1.5.4 book - Part 180 of 185
The Ring programming language version 1.5.4 book - Part 180 of 185The Ring programming language version 1.5.4 book - Part 180 of 185
The Ring programming language version 1.5.4 book - Part 180 of 185Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 176 of 181
The Ring programming language version 1.5.2 book - Part 176 of 181The Ring programming language version 1.5.2 book - Part 176 of 181
The Ring programming language version 1.5.2 book - Part 176 of 181Mahmoud Samir Fayed
 
Dot Net Framework
Dot Net FrameworkDot Net Framework
Dot Net Frameworkssa2010
 
Visual basic 6.0
Visual basic 6.0Visual basic 6.0
Visual basic 6.0Aarti P
 
ptu3-harvey-m-deitel-paul-j-deitel-tem-r-nieto-contributor-paul-j-deitel.pdf
ptu3-harvey-m-deitel-paul-j-deitel-tem-r-nieto-contributor-paul-j-deitel.pdfptu3-harvey-m-deitel-paul-j-deitel-tem-r-nieto-contributor-paul-j-deitel.pdf
ptu3-harvey-m-deitel-paul-j-deitel-tem-r-nieto-contributor-paul-j-deitel.pdfjorgeulises3
 
(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_netNico Ludwig
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010Satish Verma
 
Software Language Design & Engineering: Mobl & Spoofax
Software Language Design & Engineering: Mobl & SpoofaxSoftware Language Design & Engineering: Mobl & Spoofax
Software Language Design & Engineering: Mobl & SpoofaxEelco Visser
 
Net framework
Net frameworkNet framework
Net frameworkjhsri
 
Dot netsupport in alpha five v11 coming soon
Dot netsupport in alpha five v11 coming soonDot netsupport in alpha five v11 coming soon
Dot netsupport in alpha five v11 coming soonRichard Rabins
 
Automated Multiplatform Compilation and Validation of a Collaborative Reposit...
Automated Multiplatform Compilation and Validation of a Collaborative Reposit...Automated Multiplatform Compilation and Validation of a Collaborative Reposit...
Automated Multiplatform Compilation and Validation of a Collaborative Reposit...Ángel Jesús Martínez Bernal
 
The GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersThe GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersAlessandro Sanino
 

Similar to VB Dot net (20)

Bt0082 visual basic
Bt0082 visual basicBt0082 visual basic
Bt0082 visual basic
 
2310 b 03
2310 b 032310 b 03
2310 b 03
 
Visual studio.net
Visual studio.netVisual studio.net
Visual studio.net
 
Visual Studio.NET
Visual Studio.NETVisual Studio.NET
Visual Studio.NET
 
The Ring programming language version 1.5.4 book - Part 180 of 185
The Ring programming language version 1.5.4 book - Part 180 of 185The Ring programming language version 1.5.4 book - Part 180 of 185
The Ring programming language version 1.5.4 book - Part 180 of 185
 
The Ring programming language version 1.5.2 book - Part 176 of 181
The Ring programming language version 1.5.2 book - Part 176 of 181The Ring programming language version 1.5.2 book - Part 176 of 181
The Ring programming language version 1.5.2 book - Part 176 of 181
 
Dot Net Framework
Dot Net FrameworkDot Net Framework
Dot Net Framework
 
Introduction to Visual Studio.NET
Introduction to Visual Studio.NETIntroduction to Visual Studio.NET
Introduction to Visual Studio.NET
 
Visual basic 6.0
Visual basic 6.0Visual basic 6.0
Visual basic 6.0
 
ptu3-harvey-m-deitel-paul-j-deitel-tem-r-nieto-contributor-paul-j-deitel.pdf
ptu3-harvey-m-deitel-paul-j-deitel-tem-r-nieto-contributor-paul-j-deitel.pdfptu3-harvey-m-deitel-paul-j-deitel-tem-r-nieto-contributor-paul-j-deitel.pdf
ptu3-harvey-m-deitel-paul-j-deitel-tem-r-nieto-contributor-paul-j-deitel.pdf
 
(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net
 
Lab 1 Essay
Lab 1 EssayLab 1 Essay
Lab 1 Essay
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
 
Tml for Objective C
Tml for Objective CTml for Objective C
Tml for Objective C
 
Software Language Design & Engineering: Mobl & Spoofax
Software Language Design & Engineering: Mobl & SpoofaxSoftware Language Design & Engineering: Mobl & Spoofax
Software Language Design & Engineering: Mobl & Spoofax
 
Net framework
Net frameworkNet framework
Net framework
 
Dot netsupport in alpha five v11 coming soon
Dot netsupport in alpha five v11 coming soonDot netsupport in alpha five v11 coming soon
Dot netsupport in alpha five v11 coming soon
 
Automated Multiplatform Compilation and Validation of a Collaborative Reposit...
Automated Multiplatform Compilation and Validation of a Collaborative Reposit...Automated Multiplatform Compilation and Validation of a Collaborative Reposit...
Automated Multiplatform Compilation and Validation of a Collaborative Reposit...
 
VB.Net Mod1.pptx
VB.Net Mod1.pptxVB.Net Mod1.pptx
VB.Net Mod1.pptx
 
The GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersThe GO Language : From Beginners to Gophers
The GO Language : From Beginners to Gophers
 

Recently uploaded

Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Globus
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandIES VE
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAlluxio, Inc.
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfkalichargn70th171
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfkalichargn70th171
 
GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisNeo4j
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...Juraj Vysvader
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfAMB-Review
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageGlobus
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobus
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareinfo611746
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfOrtus Solutions, Corp
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...informapgpstrackings
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
 

Recently uploaded (20)

Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysis
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 

VB Dot net

  • 2. Today’s Discussion  What We Expect From Language?  What is new in .NET?  Comparisons with Previous Technologies / JAVA / VB-6 etc.  First Look of VB .NET
  • 3. What is in Language?  Interaction With Other Language  Platform Support  Programming Technique (structured ? Procedural? OOP?)  Databases Support  Database Handling Technique  Thread Model  Component Designing?
  • 4.  Network Support Programming? (Socket Programming)  Internet Programming ?  Future / Reliability?
  • 5. What is new in .NET Technology .NET Framework covers all the layers of software development from the operating system up
  • 6. .NET Framework ASP.NET Web Services Web Forms ASP.NET Application Service Windows Forms Controls Drawing Windows Application Service .NET Framework Base Classes ADO.NET XML Threading IO Net Security Diagnoses Etc. Common Language Runtime Memory Management Common Type System Lifecycle Monitoring
  • 7. Windows Forms (Winforms) Windows Form are a new way to create Standard WIN32 Desktop Application based on the Windows Foundation Classes(WFC)
  • 8. Web Forms Web Forms provide a powerful, form based user interface for web, it also contains additional .net ASP controls which was not present in previous versions, These controls provide Sever based events facility so that our application can be develop more easily and attractive.
  • 9. Web Services Provides a mechanism for programs to communicate over the Internet using SOAP (Simple Object Access Protocol). Web Services provide an analog of Com and DCOM for object brokering and interfacing, but based on internet technologies so that allowance is made for integration, even with non Microsoft plateforms
  • 10. CLR (Common Language Runtime) Common Type System Data Types / etc Intermediate Language to Native Code Compiler Execution Support Security Garbage Collection Memory Management(Previous version it was done by OS)
  • 11. Multiple Language Support .Net Environment Provides Multiple language Integration Support, se that we can use multiple Languages in single program. For Example we can C# function in ASP.NET as well as in VB.NET Cross language Inheritance is also Possible So Mix Language development team can also participate to develop program. How IT is Possible ? Answer CLR
  • 12. Common Type System All Languages use same Data types, their Length, Size, Type and specificaton will be same. For example in Previous VB-6 use 16 bit Integer (2 bytes) In Visual C integer was 4 Bytes. Now For all .NET Support languages use int32 Integer for 4 Bytes.
  • 13. Common Types Boolean Sbyte (Signed Byte) Byte Single Char Date/Time Decimal Double Int16 Int32 Int46
  • 14. Execution Support JIT (Just in Time Compilation and Execution) JIT Compiles with three methods: 1) Standard JIT: it Convert to exe code at the time of execution 2) Pre JIT: it it convert to exe code at the time of installation. 3) Econo JIT: it create low Optimization code, for low memory resources
  • 15. Programming Technique OOP (Object Oriented Programming) a) Encapsulation b) Inheritance c) Polymorphism
  • 16. Form Level Inheritance 1 2 1 2 3 4 Form 1 Form2 inherited from Form1
  • 17. Database Handling It use ADO+ or ADO.NET To handle different Databases Disconnected Databases SQL OLEDB Drivers (Will be discuss in Detail)
  • 18. XML Support  It Gives XML support to represent Fast Data
  • 20. Today’s Discussion  VS.NET (Visual Studio.net Environment)  Working With WinForms & important Properties  Working With Events in .NET  Data Base Creation with MS-SQL Server  Database Handling with VS.NET
  • 22.
  • 23.
  • 25.
  • 27.  Import System.Data  Import System.data.ADO  Create and set SQLConnection  Create and set SQL DataAdapter  Create and set Dataset
  • 28. Steps to Create & Set SqlConnection 1. Place SqlConnection To Form (from Data toolBox) 2. Set its name property to con1 3. Set its Connection Property using connection Wizard
  • 29. Steps to Create & Set DataAdapter 1. Put DataAdapter Control to form 2. Right click on That Control 3. Select Configure 4. Follow Steps to complete Process 5. Right Click on DataAdapter Control, and select Create DATASET
  • 30. Put Following Code on Form’s Load Event Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load da1.Fill(ds1, "ghufi") End Sub
  • 32. Private Sub cmdLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLast.Click cnt = Me.ds1.Tables("ghufi").Rows.Count Me.BindingContext(ds1, "ghufi").Position = Me.BindingContext(ds1, "ghufi").Count - 1 MsgBox(cnt.ToString) End Sub Private Sub cmdNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNext.Click Me.BindingContext(ds1, "ghufi").Position = Me.BindingContext(ds1, "ghufi").Position + 1 End Sub
  • 33. Private Sub cmdPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPrev.Click Me.BindingContext(ds1, "ghufi").Position = Me.BindingContext(ds1, "ghufi").Position - 1 End Sub Private Sub cmdFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFirst.Click Me.BindingContext(ds1, "ghufi").Position = 0 End Sub
  • 34. Todays Discussion  Few Language Tips  How To search  Working wit DataGrid  Add Records  Save Records
  • 35. Few Language Changes  Data Types  Declaration Methods  Type Casting  Option keyword  Changes in Array
  • 36. Data Types (Integers)  Byte 8 Bits 0 to 255  Short  Integer  Long
  • 38. Others  Char  String  Varient  Object
  • 39. Declaration of Variables  Dim I , j , k as integer
  • 40. Option  Option Explicit On/Off  Option Compare Binary/Text  Option Strict On/Off (Data type conversion)
  • 41. Find Records On Load txtfind.Text = ds1.ghufi.Columns.Count() ComboBox1.Items.Add(ds1.ghufi.Columns(0).ColumnName) ComboBox1.Items.Add(ds1.ghufi.Columns(1).ColumnName) ComboBox1.Items.Add(ds1.ghufi.Columns(2).ColumnName) ComboBox1.Items.Add(ds1.ghufi.Columns(3).ColumnName)
  • 42.
  • 43. Write Following Code under Find Dim fldname As String fldname = ComboBox1.SelectedItem() ds1.Clear() da1.SelectCommand.CommandText = "select * from ghufi where " & fldname & "='" & txtfind.Text & "'“ da1.Fill(ds1, "ghufi") If Me.BindingContext(ds1, "ghufi").Count <= 0 Then MsgBox("Sorry No Record for your Search") End If
  • 44. Today’s Discussion (03/11/2002)  New Control “Notify Icon”  How to Navigate B/W Forms  Inheritance in Forms  How User Master Details  Add / Save
  • 45. NotifyIcon Control Notify Icon is a new control which put a link on System Tray, it automatically creates a new panel in system tray and shows Icon. It’s Click Event Fires when we double click on that Icon. We may use it for new form load, or terminate Application.
  • 46. Steps to use NotifyTray  Drag and drop this control on Form  Set it’s Icon Property with any suitable Icon  Write “End” to its click event
  • 48. Put Form1 as Following
  • 50. Its coding is Public Class Form4 Inherits System.Windows.Forms.Form Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class
  • 51. Change this coding as Public Class Form4 Inherits System.amin.form3 Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class Set form4 as Default For and Run Program
  • 52. Come back to Database Master Details Forms
  • 57. Code on ListIndexChanged ds2.Clear() da2.SelectCommand.CommandText = "select * from ghufi_details where id=" & CInt(sender.Text) da2.Fill(ds2, "ghufi_details")
  • 61.  FileDialogBox  SaveDialogBox  FontDialogBox  ColorDialogBox  PrintDialogBox
  • 62. Screen For Dialog Boxes Open Save Font Color Print
  • 63. Today’s Discussion (18/11/2002)  Add New Record with Programming  Edit Record  Delete Record
  • 64. OpenFileDialogBox Imports System.IO openDialog.Filter = "Text Files (*.txt)|*.txt|All Files|*.*“ openDialog.FilterIndex = 1 openDialog.InitialDirectory = "c:“ openDialog.Title = "Demo Open Dialog“ openDialog.ShowDialog() strfilename = openDialog.FileName Dim objreader As StreamReader = New StreamReader(strfilename) TextBox1.Text = objreader.ReadToEnd
  • 65. objreader.Close() objreader = Nothing Do Until objreader.Read = -1 TextBox1.Text = TextBox1.Text & objreader.ReadLine & vbCrLf Loop
  • 66. SaveDialog & FileStreamWriter With saveDialog .DefaultExt = "txt“ .FileName = strfilename .Filter = "Text Files(*.txt)|*.txt|All Files|*.*“ .FilterIndex = 1 .InitialDirectory = "c:“ .OverwritePrompt = True .Title = "File Save Demo“ End With saveDialog.ShowDialog() strfilename = saveDialog.FileName
  • 67. Dim objwriter As StreamWriter = New StreamWriter(strfilename, False) objwriter.Write(TextBox1.Text) objwriter.Close() objwriter = Nothing
  • 70. Print Dialog PrintDialog.AllowPrintToFile = False PrintDialog.AllowSelection = False PrintDialog.AllowSomePages = False PrintDialog.ShowDialog()
  • 72. Steps To Design Menu  There are two Types of Menues – Main Menu – Context Menu
  • 73. Main Menu This Menu Appear Normally on the Top of the form, this is very common menu for windows base applications. ie. File, Edit, View etc Context Menu This menu is Small Menu Which appears when user right click on Any Form Item
  • 74. Steps To Design Main Menu  Drag and drop main menu from Toolbox  Write Menu Name  Use & for Access Keys  Set Properties of every menu – Name – Shortcut
  • 75. Steps Context Menu  Drag and drop Context menu from ToolBox  Design some menu items Every Control has Context menu property, we bind context menu property to context menu, so that menu will appear when user right click on that menu
  • 78. Declarations Public Class Form2 Inherits System.Windows.Forms.Form Public con As OleDbConnection = New OleDbConnection("Provider=Microsoft.jet. oledb.4.0; data source=d:LibrarySystemlibrary.mdb") Public da As OleDbDataAdapter Public ds As DataSet Public dw As DataView Public cm As CurrencyManager
  • 79. Initializations (call two functions) 'Add any initialization after the InitializeComponent() call FillData() bindFields()
  • 80. FillData Function Private Sub FillData() dw = Nothing ds = New DataSet() con.Open() da = New OleDbDataAdapter("select * from books", con) da.Fill(ds, "books") dw = New DataView(ds.Tables("books")) cm = CType(Me.BindingContext(dw), CurrencyManager) con.Close() End Sub
  • 81. DataBinding Function Private Sub bindFields() TextBox1.DataBindings.Clear() TextBox2.DataBindings.Clear() TextBox1.DataBindings.Add("text", dw, "code") TextBox2.DataBindings.Add("text", dw, "Name") End Sub
  • 82. Add Button Code TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = ""
  • 83. Save Button Dim pos As Integer pos = cm.Position Dim cmd As New OleDbCommand() cmd.Connection = con cmd.CommandText = "Insert into books (code, name, author) values(?,?,?)“ cmd.CommandType = CommandType.Text con.Open()
  • 84. cmd.Parameters.Add(New OleDbParameter()) cmd.Parameters.Item(0).Direction = ParameterDirection.Input cmd.Parameters.Item(0).DbType = DbType.String cmd.Parameters.Item(0).Size = 10 cmd.Parameters.Item(0).Value = TextBox1.Text
  • 85. Try cmd.ExecuteNonQuery() Catch ex As Exception MsgBox("Error:=" & ex.Message) End Try con.Close() FillData() bindFields() MsgBox("Record Added") ds = Nothing da = Nothing cmd = Nothing
  • 86. Edit cmd.CommandText = "update books set name=?,author=? where code=?" cmd.CommandType = CommandType.Text
  • 87. Delete cmd.CommandText = “delete from books where code=?" cmd.CommandType = CommandType.Text Pos=1
  • 89. Handling ADO With Coding By Akber Ahmed Khowaja
  • 90. Code for Import Files Imports System.Data Imports System.Data.OleDb Imports System.DBNull Public Class Form2 . . . . . . . . . .
  • 91. Variable Declaration • For Connection • For Data Adapter • For Dataset
  • 92. Few Slides Are Remaining
  • 93. Today’s Discussion (Dec 02, 2002)  Concept Of OOP  What is Class  Simple Class  Methods  Constructors  Properties  Data Base Handling With Class
  • 94. What is OOP OOP is Programming technique in which we make programs Flexible and Reusable. Basic Concept of OOP is Designing Classes in Program.
  • 95. What is Class Class is Collection of Data / Properties and Methods/Functions which operate on that data. Methods and Data are Encapsulated in Class, is called Encapsulation We may Inherit functionality of one class to other class is called Inheritance. With class one object may work with different ways is called Polymorphism
  • 96. A Simple Class Write Click On Project add Class to your project Public Class Person Public FName As String Public LName As String Public Age As Integer End Class
  • 97. Form for Usage of “Person” class
  • 98. Create Object for “Person” Class Dim p1 As New Person()
  • 99. Code for Insert Data / Show Data Buttons p1.FName = TextBox1.Text p1.LName = TextBox2.Text p1.Age = CInt(TextBox3.Text) TextBox1.Text = p1.FName TextBox2.Text = p1.LName TextBox3.Text = p1.Age
  • 100. Encapsulation (Private Data and Access public Methods) Public Class Person Private FName As String Private LName As String Private Age As Integer 'setdata Method Public Sub setData(ByVal Fnm As String, ByVal LNm As String, ByVal ag As Integer) FName = Fnm LName = LNm Age = ag End Sub
  • 101. Public Function getFName() As String Return (FName) End Function Public Function getLName() As String Return (LName) End Function Public Function getAge() As Integer Return (Age) End Function End Class
  • 102. Constructor Constructor is Special Type of method which call automatically when object creates, we may use constructor for data initialization. Public Sub New() FName = "FName Not Set" LName = "LName Not Set" Age = 0 End Sub
  • 103. Array Of Objects Dim p(10) As Person Dim cntr As Integer
  • 104. Screen For Use Array of Objects
  • 105. Code for Set Data Button p(cntr) = New Person() p(cntr).setData(TextBox1.Text, TextBox2.Text, CInt(TextBox3.Text)) MsgBox("Data Stored as index number : " & CStr(cntr)) cntr += 1
  • 106. Code for Show Data Button Dim xx As Integer xx = txtIndex.text TextBox1.Text = p(xx).getFName() TextBox2.Text = p(xx).getLName() TextBox3.Text = p(xx).getAge()
  • 107. Properties For Class Property FName() As String Get Return (XFName) End Get Set(ByVal Value As String) XFName = Value End Set End Property
  • 108. Use Properties dim t1 as new Teacher() ‘ teacher is class t1.FName = TextBox1.Text t1.LName = TextBox2.Text t1.Age = TextBox3.Text
  • 109. Data base Handling with class Public Class DataClass Public con As OleDbConnection Public da As OleDbDataAdapter Public ds As DataSet Public dw As DataView Public cm As CurrencyManager
  • 110. Method Open Connection Public Sub openConnection(ByVal constr As String) con = New OleDbConnection(constr) con.Open() End Sub ‘’’’’’’’’’’’’’’’’’’’’’’’’’’’ Private Sub setDa(ByVal sqlstr As String, ByVal cn As OleDbConnection) da = New OleDbDataAdapter(sqlstr, cn) End Sub
  • 111. Public Sub FillData(ByVal sqlstr As String, ByVal dbnm As String, ByVal tblnm As String) dw = Nothing ds = New DataSet() OpenConnection("Provider=Microsoft.jet.oledb.4.0; data source=f:Inventory_VBNETInventorySystem" & dbnm) setDa(sqlstr, con) da.Fill(ds, tblnm) dw = New DataView(ds.Tables(tblnm)) con.Close() End Sub
  • 112. Move Records Public Sub MoveRecord(ByVal bc As BindingContext, ByVal tblnm As String, ByVal symbol As String) If symbol = ">" Then bc(ds, tblnm).Position += 1 ElseIf symbol = "<" Then bc(ds, tblnm).Position -= 1 ElseIf symbol = "<<" Then bc(ds, tblnm).Position = 0 ElseIf symbol = ">>" Then bc(ds, tblnm).Position = bc(ds, tblnm).Count – 1 End If
  • 113. Usage ‘Create Object Dim obj As New DataClass() 'Add any initialization after the InitializeComponent() call obj.FillData("select * from items", "Inventory.mdb", "Items") showData()
  • 114. Private Sub showData() Dim pos As Integer pos = Me.BindingContext(obj.ds, "items").Position TextBox1.Text = obj.ds.Tables("items").Rows(pos).Item("itemName") End Sub Show Data Method
  • 115. Code For Next Button_Click obj.MoveRecord(Me.BindingContext, "Items", ">") showData()