VPT Lab Anchit
VPT Lab Anchit
VPT Lab Anchit
Techniques
Introduction to .NET
.NET is a set of common services which can be used on a number
of common languages. These services are executed in the form of
executable code i.e. independent of underlying architecture.
Source
Code
Executable
Code
MSIL
JIT
Compiler
Executio
n
Architecture of VB.NET
.NET framework is Multilanguage environment for
building and running web services, web applications and
windows application. .Net technology aims in providing a
platform for building internet based application in a
faster, efficient and much more reliable manner.
Features Of .NET
2 (Amit Rajput 06/CS/007)
1) .NET is Multilanguage : With .NET platform we can
use several languages. Ex- Vb, C#, J# ,Jsp etc. All these
languages are compiled through an intermediate binary
code which is independent of hard-ware , operating
system and underlying architecture.
Dim A As Double
Dim B As Char
TB1.Text = "0"
End Sub
End Sub
End Sub
End Sub
End Sub
End Sub
End Sub
End Sub
End Sub
End Sub
End Sub
Dim l As Integer
l = TB1.Text.Length
If l = 0 Then
Else
TB1.Text = TB1.Text.Remove(l - 1, 1)
Else
End If
End If
End Sub
TB1.Text = ""
TB1.Focus()
A = TB1.Text
TB1.Clear()
B = "+"
TB1.Focus()
End Sub
A = TB1.Text
TB1.Clear()
B = "-"
TB1.Focus()
End Sub
A = TB1.Text
TB1.Clear()
B = "*"
TB1.Focus()
End Sub
TB1.Clear()
B = "/"
TB1.Focus()
End Sub
TB1.Text = Math.Sqrt(TB1.Text)
End Sub
Dim l As Integer
l = TB1.Text.Length
TB1.Text = TB1.Text.Remove(l - 1, 1)
End Sub
A = TB1.Text
TB1.Clear()
B = "P"
TB1.Focus()
End Sub
TB1.Clear()
B = "%"
TB1.Focus()
End Sub
If B = "+" Then
TB1.Text = A + Val(TB1.Text)
TB1.Text = A - Val(TB1.Text)
TB1.Text = A * Val(TB1.Text)
TB1.Text = A / Val(TB1.Text)
Dim C As Double
C = TB1.Text
TB1.Text = Math.Pow(A, C)
End If
End Sub
End Class
End Sub
Dim a As Integer
Dim b As Integer
Dim c As Integer
Try
a = TextBox1.Text
b = TextBox2.Text
c = a + b = TextBox3.Text
Catch ex As InvalidCastException
MsgBox(ex.Message)
End Try
End Sub
Dim a As Integer
Dim b As Integer
Dim c As Integer
Try
a = TextBox1.Text
b = TextBox2.Text
c = a \ b
MsgBox(ex.Message)
End Try
End Sub
Dim a As Integer
Dim b As Integer
Dim c As Integer
Try
a = TextBox1.Text
b = TextBox2.Text
c = a + b
TextBox3.Text = c
Catch ex As OverflowException
MsgBox(ex.Message)
End Try
End Sub
Try
a(0) = 1
a(1) = 2
a(2) = 3
Catch ex As IndexOutOfRangeException
MsgBox(ex.Message)
End Try
Dim a As String
Dim b As String
Try
b = a.ToUpper()
Catch ex As NullReferenceException
MsgBox(ex.Message)
End Try
End Sub
Dim a As Integer
Dim b As Integer
Dim c As Integer
a = TextBox1.Text
b = TextBox2.Text
c = a / b
TextBox3.Text = c
End Sub
End Class
Dim c1 As Integer
c1 = TextBox1.Text
a.evenorodd(c1)
End Sub
a1 = TextBox1.Text
b1 = textbox2.text
c.swap(a1, b1)
End Sub
Dim a1 As Integer
a1 = TextBox1.Text
b.revofnum(a1)
End Sub
Dim a1 As Integer
a1 = TextBox1.Text
b.prime(a1)
End Sub
End Class
rem1 = b Mod 2
If rem1 = 0 Then
MsgBox("even")
Else
MsgBox("odd")
End If
End Function
Dim t As Integer
t = a
a = d
d = t
End Function
rem1 = a Mod 10
a = a / 10
End While
MsgBox(sum1)
End Function
For i = 2 To a / 2
If a Mod i = 0 Then
flag = flag + 1
End If
Next
MsgBox("not prime")
Else
MsgBox("prime")
End If
End Function
End Class
Dim p, r, t As Double
Get
mr = r
End Get
r = value
End Set
End Property
Get
mp = p
End Get
p = value
End Set
End Property
Get
mt = t
End Get
t = value
End Set
Dim h As Double
h = ((p * r * t) / 100)
Return (h)
End Function
End Class
Dim k As Double
a.mp = TextBox1.Text
a.mr = TextBox2.Text
a.mt = TextBox3.Text
k = a.si
MsgBox(k)
End Sub
End Class
Imports System.Drawing.Drawing2D
Dim a, b, c, d As Integer
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Val(TextBox3.Text)
d = Val(TextBox4.Text)
Dim g As Graphics
g = Me.CreateGraphics
g.DrawLine(p, a, b, c, d)
End Sub
Dim g As Drawing.Graphics
Dim a, b, c, d As Integer
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Val(TextBox3.Text)
d = Val(TextBox4.Text)
g = Me.CreateGraphics
g.DrawRectangle(p, a, b, c, d)
End Sub
Dim g As Drawing.Graphics
Dim a, b, c, d As Integer
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Val(TextBox3.Text)
d = Val(TextBox4.Text)
g = Me.CreateGraphics
g.DrawEllipse(p, a, b, c, d)
End Sub
Dim g As Drawing.Graphics
Dim a, b, c, d As Integer
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Val(TextBox3.Text)
d = Val(TextBox4.Text)
Dim r As Rectangle
g = Me.CreateGraphics
r = New Rectangle(a, b, c, d)
g.FillRectangle(brush, r)
End Sub
Dim g As Drawing.Graphics
Dim a, b, c, d As Integer
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Val(TextBox3.Text)
d = Val(TextBox4.Text)
Dim r As Rectangle
g = Me.CreateGraphics
r = New Rectangle(a, b, c, d)
g.DrawEllipse(p, a, b, c, d)
g.FillEllipse(brush, r)
End Sub
Dim g As Drawing.Graphics
Dim a, b, c, d As Integer
b = Val(TextBox2.Text)
c = Val(TextBox3.Text)
d = Val(TextBox4.Text)
Dim r As Rectangle
g = Me.CreateGraphics
r = New Rectangle(a, b, c, d)
g.Fillrectangle(brush, r)
End Sub
Dim g As Drawing.Graphics
Dim a, b, c, d As Integer
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Val(TextBox3.Text)
d = Val(TextBox4.Text)
Dim r As Rectangle
g = Me.CreateGraphics
r = New Rectangle(a, b, c, d)
g.DrawRectangle(p, a, b, c, d)
p.DashStyle = DashStyle.DashDot
End Class
OUTPUT:-GRAPHICS
Program –6
Imports System.Drawing.Drawing2D
Imports System.Drawing.graphics
mousepath.StartFigure()
End If
End Sub
End If
PictureBox1.Invalidate()
End Sub
e.Graphics.DrawPath(p, mousepath)
End Sub
End Class
If (Timer1.Enabled) Then
Button1.Text = "restart"
Timer1.Stop()
Else
starttimer = DateTime.Now()
Button1.Text = "stop"
Timer1.Start()
End If
End Sub
span = DateTime.Now.Subtract(starttimer)
End Sub
End Class
OUTPUT:- INTEROPERABILITY
Form -1 coding
Imports System.Data.OleDb
Dim k As String
k = "married"
Else
k = "unmarried"
End If
str1 = "insert into priya(name,address,phno,status)values('" & TB1.Text & "','" & TB2.Text &
"','" & TB3.Text & "',' " & k & "') "
comm.ExecuteNonQuery()
TB1.Clear()
TB2.Clear()
TB3.Clear()
End Sub
conn.Open()
End Sub
a.show()
Me.Hide()
conn.Close()
End Sub
End Class
Form-2 Coding
Imports system.data.oledb
str3 = "select * from priya where name='" & ComboBox1.Text & "'"
reader = comm.ExecuteReader()
While (reader.Read)
tb2.Text = (reader("address"))
tb3.Text = (reader("phno"))
If rb1.Text = s Then
rb1.Checked = True
Else
rb2.Checked = True
End If
End While
ComboBox1.Focus()
End Sub
conn.Open()
reader = comm.ExecuteReader()
While (reader.read)
ComboBox1.Items.Add(reader("name"))
End While
reader.close()
End Sub
Dim k As String
k = "married"
Else
k = "unmarried"
str4 = "Update kavita set address='" & tb2.Text & "',phno='" & tb3.Text & "',status='" & k &
"' where name = '" & ComboBox1.SelectedItem & "' "
comm.ExecuteNonQuery()
tb2.Clear()
tb3.Clear()
rb1.Checked = False
rb2.Checked = False
End Sub
str5 = "delete from priya where name='" & ComboBox1.SelectedItem & "' "
comm.ExecuteNonQuery()
tb2.Clear()
tb3.Clear()
rb1.Checked = False
rb2.Checked = False
End Sub
a.Show()
Me.Hide()
conn.Close()
End Sub
End Class
Dim dt As DataTable
Dim ds As DataSet
Me.BindingContext(ds, "table1").Position = 0
End Sub
Me.BindingContext(ds, "table1").Position += 1
End Sub
Me.BindingContext(ds, "table1").Position -= 1
End Sub
End Sub
ds = New DataSet
adap.Fill(ds, "table1")
End Sub
dt = ds.Tables("table1")
dsnewrow = dt.NewRow()
dsnewrow.Item("name") = TextBox1.Text
dsnewrow.Item("address") = TextBox2.Text
dsnewrow.Item("age") = TextBox3.Text
dsnewrow.Item("status") = TextBox4.Text
dt.Rows.Add(dsnewrow)
adap.Update(ds, "table1")
End Sub
Program - 10
Aim : To implement complex Binding
40 (Amit Rajput 06/CS/007)
Imports System.Data.OleDb
Dim ds As DataSet
ds = New DataSet
adap.Fill(ds, "table1")
DataGridView1.DataSource = ds.Tables("table1")
End Sub
End Class