VB .NET 2008 VB DOT NET SYLLABUS 30 Hours CLASS: 1 (THEORY) 1 Introduction to Dot Net 2 VB Dot Net Project Type 3 Features of VB Dot Net 4 Introduction to Console Based project 5 If condition 6 For Loop 7 For Each Loop 8 Select Case 9 Goto Statement CLASS: 2 (THEORY) 10Standard Array 11Dynamic Array 12Date & Time Function 13String Function 14Math Function 15Conversion Function CLASS: 3 (THEORY) 16Exception handling 17Enumeration THANKING YOU CREATED BY A.KARTHIKEYAN
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
VB .NET 2008
VB DOT NET SYLLABUS 30 Hours
CLASS: 1 (THEORY) 1 Introduction to Dot Net2 VB Dot Net Project Type3 Features of VB Dot Net4 Introduction to Console Based project5 If condition6 For Loop7 For Each Loop8 Select Case9 Goto Statement
CLASS: 2 (THEORY) 10Standard Array11Dynamic Array12Date & Time Function13String Function14Math Function15Conversion Function
88 Image List89Error Provider90TrackBar91Windows Media Player
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
CLASS: 14 (THEORY) 92My Computer Object 93My User Object
CLASS: 15 (THEORY) 94Advanced Concept in Vb.Net95 (Cryptography) Public Key Encryption96 (Cryptography) Secret Key File97File Input and Output98 File Access Lib99 File Access Application
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
DOT NET
Dot Net Framework:
A framework is in which windows application may be developed and run the Dot NetWork based on Dot Net Frame work.
E.g. Frame work 2.0, 2.5, 3.0, 3.5
Using Front End software:
Four types of Dot Net:
1) Visual Basic Dot Net
2) C Sharp Dot Net
3) Asp Dot Net
4) C++ Dot Net
Here ADO is not software
It is data connection concept
Using Back End software:
1) SQL Server
2) Oracle
3) Ms Access
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
THANKING YOU
CREATED BY A.KARTHIKEYAN
.NE
T FRA
ME
WO
RK
2.0 &SP1
OPERATING SYSTEM HARDWARE
VISU
AL ST
UD
IO .N
ET
COMMON LANGUAGE RUNTIME (CLR)
. NET FRAME WORK BASE CLASS LIBRARY
WINDOWS
FORMS
ASP. NET CONSOLE
FORMS
ADO. NET
. NET FRAME WORK CLASS LIBRARY
COMMON TYPE SYSTEM
COMMON LANGUAGE SPECIFICATION
C# VB. NET VISUAL C++
OTHER. NET LANGUAGE
.NE
T FRA
ME
W
OR
K 3.0 &
SP1.N
ET FR
AM
E
WO
RK
3.5
LINQ ASP. NET 3.5
ADO .NET ENTITY
FRAME WORK & DATA
SERVICES
ADDITIONAL ENHANCEMENTS
WINDOWS PRESENTATION FOUNDATION
(WPF)
WINDOWS COMMUNICATION
FOUNDATION (WCF)
WINDOWS WORK FLOWS FOUNDATION
(WFF)
WINDOWS CARD SPACES (WCF)
VB .NET 2008
VISUAL DOT NET-2008
INTRODUCTION:
VB Dot Net is based on GUI
VB Dot Net is Not a case sensitive
VB Dot Net is also pure OOPs
VB Dot Net is creating distributed applications
IDE provides with a centralized location for designing the user interface for the application, writing code & Compile & Debugging the applicationWay to Open Dot Net:
Start All programs Microsoft Visual Studio 2008 Microsoft Visual Studio 2008 Click
VB Dot Based on Two types of Application:
1) Based on Console Application
2) Based on Windows Application
Way to Open New Console Project:
File New Project (Ctrl+Shift+N) Click
Project TypeVisual Basic WindowsConsole Application File name pathOk
Way to Open New Windows Project:
File New Project (Ctrl+Shift+N) Click
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Project TypeVisual Basic WindowsWindows Form Application File name pathOk
VB DOT NET Shortcut Key:
Meaning Shortcut key
New Project Ctrl+Shift+N
Server Explorer Ctrl+Alt+S
Toolbox Explorer Ctrl+Alt+X
Solution Explorer Ctrl+Alt+L
Properties F4
Run F5
Visual Basic Project Type Meaning
Console Application Created Console Application
Windows Application Created Windows Application
Class Library Create a reusable code library(*.dll files)
Empty Project Import existing files into a new project
Variable Declaration:
Dim <Access Specifies> <Variable name> as <Data type>
Eg:
Dim a as string
Data types:
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
String, Object, Date, Integer, Byte, Boolean, Single, Short, Char, Double, Long
Front and Back double code Eg: “Hello” Eg: “c”THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Windows Projects
CLASS: 5 (THEORY)
Project: 1
‘Eg for Access Control
Form Design:
‘
Form Coding:Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MsgBox("ALT+C shortcut key") End SubEnd Class
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Legends:Button1.text=& Click me
Project: 2
‘E.g. for Add Control
Form Design:
‘
Form Coding:
Public Class Form1
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated Dim b1 As Button = New Button() b1.Name = "b1" b1.Size = New Size(150, 20) b1.Location = New Point(100, 100) b1.Text = "Hello World of Coding" Controls.Add(b1) End SubEnd Class
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Legends:
Project: 3
‘E.g. for Input box and Msgbox
Form Design:
‘
Form Coding:Public Class Form1
Dim a, b As Integer Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
a = InputBox("Enter the a value:") b = InputBox("Enter the b value:") MsgBox("value is:" & a + b)
End Sub
End Class
Legends:THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Button1.text=Addition
Button1.font=Choose any font name with size
Button1.backcolor= choose any color
Form1.backcolor=choose any color
Project: 4
‘E.g. for Enable true and false & Visible true and false
Form Design:
Form Coding:Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MonthCalendar1.Enabled = True End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click MonthCalendar1.Enabled = False End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click MonthCalendar1.Visible = False End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click MonthCalendar1.Visible = True End SubEnd Class
Legends:
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Button1.text=ENABLE TRUE
Button2.text=ENABLE FALSE
Button3.text=VISIBLE TRUE
Button4.text=VISIBLE FALSE
Project: 5
‘E.g. for Mouse Events
Form Design:
Form Coding:Public Class Form1 Private Sub Form1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDoubleClick MsgBox("Mouse double click")
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
End Sub
Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel MsgBox("mouse wheel scrolled") End Sub
End Class
Project: 5
‘E.g. for Keyboard Events
Form Design:
Form Coding:Public Class Form1 Dim i Dim s As String() = New String() {"i", " ", "a", "m", " ", "l", "o", "o", "s", "e", " "} Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick For i = 0 To 10 Step 1 RichTextBox1.Text = RichTextBox1.Text & s(i) Next End SubEnd Class
Legends:Timer1.Interval=1000Timer1.Enabled =true
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
RichTextbox1.text=””Form1.text=My Text EditorForm1.icon= Choose any icon
To prepare complete Software:Go to Build Menu Publish Click Choose any Location Next Next Finish
CLASS: 6 (THEORY)
Project: 1
‘Eg for Label, Button, Picture box, Group box, Textbox, Radio button FORM DESIGN:
Legends:Form1.startup=Center Screen
Label1.text=Enter the Username:
Label2.text=Enter the Password:
Textbox1.PasswordChar=*
Button1.text=Login???
Picturebox1.Picture=choose any picture
Image1.Size mode=Stretch mode
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Group box1.text=select your option
Option1.text=Image1
Option2.text=Image2
Option3.text=Image3
Option4.text=Image4
Form Coding:Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load PictureBox1.Visible = False GroupBox1.Visible = False End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If TextBox1.Text = "karthi" AndAlso TextBox2.Text = "bss" Then MsgBox("login success") PictureBox1.Visible = True GroupBox1.Visible = True Else MsgBox("Login Error") TextBox1.Focus() End If End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged PictureBox1.Image = Windows_1.My.Resources.Resources.image1 End Sub
Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged PictureBox1.Image = Windows_1.My.Resources.Resources.image3 End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged PictureBox1.Image = Windows_1.My.Resources.Resources.image2 End Sub
Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged PictureBox1.Image = Windows_1.My.Resources.Resources.image4 End SubEnd Class
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Project 2:
‘EG Progress bar, Timer Control
Form Design:
LEGENDS:
Timer1.Enabled=true
Timer1.interval=100
Form1.text=Please Wait..
Label1.Text=Loading..
Form1.Controlbox=false
Form1.startup=Center Screen
Form Coding:Public Class Form1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick On Error GoTo a
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
ProgressBar1.Value = ProgressBar1.Value + 1 Label1.Text = "Loading" & ProgressBar1.Value & "%" If ProgressBar1.Value = 100 Then MsgBox("Loading completed..") Timer1.Enabled = False End Ifa: End Sub
End Class
Project 3:
‘Eg for List box, Notify icon, Check box, Option button, Mask Textbox
Form Design:
LEGENDS:
Form1.text=Application Form Filling..
Form1.startup=Center Screen
Form Coding:Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ListBox1.Items.Add("NAME:" & TextBox1.Text)
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
ListBox1.Items.Add("ADDRESS:" & RichTextBox1.Text) ListBox1.Items.Add("DOJ:" & DateTimePicker1.Value) ListBox1.Items.Add("CELL NO:" & MaskedTextBox1.Text) End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load NotifyIcon1.Visible = True End SubEnd Class
Project 4:
‘Eg for Application Developing
Form Design:
LEGENDS:
Timer1.interval=100
Timer1.enabled=true
Textbox1, 2, 3, 4, 5.Enabled =false
Form1.maximum=false
Form1.minimum=false
Form1.text=BUS MONITORING
Form1.starup=center screen
Form Coding:
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Public Class Form1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Label1.Text = "DATE:" & DateValue(Now) Label2.Text = "TIME:" & TimeValue(Now) End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load TextBox1.Text = "1" TextBox2.Text = "MTC" TextBox3.Text = TimeOfDay TextBox4.Text = "CMBT" TextBox5.Text = "PARRYS" End Sub
Private Sub Button20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button20.Click Call disp()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TextBox1.Text = TextBox1.Text & Button1.Text curval = Val(TextBox1.Text) End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Text = TextBox1.Text & Button2.Text curval = Val(TextBox1.Text) End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click TextBox1.Text = TextBox1.Text & Button3.Text curval = Val(TextBox1.Text) End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click TextBox1.Text = TextBox1.Text & Button4.Text curval = Val(TextBox1.Text) End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click TextBox1.Text = TextBox1.Text & Button5.Text
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
curval = Val(TextBox1.Text) End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click TextBox1.Text = TextBox1.Text & Button6.Text curval = Val(TextBox1.Text) End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click TextBox1.Text = TextBox1.Text & Button7.Text curval = Val(TextBox1.Text) End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click TextBox1.Text = TextBox1.Text & Button8.Text curval = Val(TextBox1.Text) End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click TextBox1.Text = TextBox1.Text & Button9.Text curval = Val(TextBox1.Text) End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click TextBox1.Text = TextBox1.Text & Button10.Text curval = Val(TextBox1.Text) End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click TextBox1.Text = TextBox1.Text & Button11.Text curval = Val(TextBox1.Text) End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click curval = preval = result = 0 TextBox1.Text = "" End Sub
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click TextBox1.Text = "" preval = curval curval = 0 choice = "+" End Sub
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click TextBox1.Text = "" preval = curval curval = 0 choice = "-" End Sub
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click TextBox1.Text = "" preval = curval curval = 0 choice = "*" End Sub
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click TextBox1.Text = "" preval = curval curval = 0 choice = "/" End Sub
Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click Select Case choice Case "+" result = preval + curval TextBox1.Text = CStr(result) Case "-" result = preval - curval TextBox1.Text = CStr(result) Case "*" result = preval * curval TextBox1.Text = CStr(result) Case "/" result = preval / curval TextBox1.Text = CStr(result) curval = Val(result) End Select End Sub
Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click curval = -curval TextBox1.Text = Str(curval) End SubEnd Class
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
CLASS: 7
FORM DESIGN:
Form Coding:
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Project: 2
Form Design:
‘Eg for Link label
Legends:
Form Coding:Public Class Form1 Private Sub GroupBox3_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox3.Enter End Sub Private Sub GroupBox2_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox2.Enter
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
End Sub Private Sub LinkLabel9_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel9.LinkClicked System.Diagnostics.Process.Start("sqlplus") End Sub Private Sub LinkLabel3_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel3.LinkClicked System.Diagnostics.Process.Start("Wordpad") End Sub Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked System.Diagnostics.Process.Start("notepad") End Sub Private Sub LinkLabel4_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel4.LinkClicked System.Diagnostics.Process.Start("cmd") End Sub Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked System.Diagnostics.Process.Start("mspaint") End Sub Private Sub LinkLabel5_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel5.LinkClicked System.Diagnostics.Process.Start("winword") End Sub Private Sub LinkLabel6_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel6.LinkClicked System.Diagnostics.Process.Start("excel") End Sub Private Sub LinkLabel7_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel7.LinkClicked System.Diagnostics.Process.Start("powerpnt") End Sub Private Sub LinkLabel8_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel8.LinkClicked System.Diagnostics.Process.Start("msaccess") End Sub Private Sub LinkLabel10_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel10.LinkClicked System.Diagnostics.Process.Start("Photoshop") End Sub Private Sub LinkLabel11_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel11.LinkClicked
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
System.Diagnostics.Process.Start("Iexplore") End Sub
Private Sub LinkLabel12_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel12.LinkClicked System.Diagnostics.Process.Start("Nero") End SubEnd Class
Project: 3 ‘Eg for Combo box, Numeric Up down
Form Design:
Form Coding:Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ComboBox1.Items.Add("PANDIAN") ComboBox1.Items.Add("ROCK FORT") ComboBox1.Items.Add("MUMBAI ") ComboBox1.Items.Add("SALEM") ComboBox1.Items.Add("VAIGAI") End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged If ComboBox1.SelectedIndex = 0 And NumericUpDown1.Value = 1 Then TextBox1.Text = "10.50" TextBox2.Text = "CHENNAI" TextBox3.Text = "MADURAI" End If If ComboBox1.SelectedIndex = 1 And NumericUpDown1.Value = 2 Then TextBox1.Text = "12.50" TextBox2.Text = "CHENNAI" TextBox3.Text = "THANJAVUR" End If If ComboBox1.SelectedIndex = 2 And NumericUpDown1.Value = 3 Then TextBox1.Text = "16.30" TextBox2.Text = "CHENNAI" TextBox3.Text = "MUMBAI" End If
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
If ComboBox1.SelectedIndex = 3 And NumericUpDown1.Value = 4 Then TextBox1.Text = "18.10" TextBox2.Text = "CHENNAI" TextBox3.Text = "SALEM" End If If ComboBox1.SelectedIndex = 4 And NumericUpDown1.Value = 5 Then TextBox1.Text = "21.50" TextBox2.Text = "CHENNAI" TextBox3.Text = "GINGEE" End If End SubEnd Class
Project: 4
‘System Terminator software creation
Form Design:
Form Coding:Public Class Form1 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick TextBox2.Text = TimeValue(Now) End Sub Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged System.Diagnostics.Process.Start("cmd") End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ComboBox1.Items.Add("ON")
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
ComboBox1.Items.Add("OFF") End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged If ComboBox1.SelectedIndex = 0 And RadioButton1.Checked = True Then If TextBox1.Text = TimeValue(Now) Then MsgBox("ok") System.Diagnostics.Process.Start("Logoff") End If End If End SubEnd Class
Project: 5 ‘Eg for CheckListbox
Form Design:
Form Coding:Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ComboBox1.Items.Add("PANDIAN") ComboBox1.Items.Add("ROCK FORT") ComboBox1.Items.Add("MUMBAI ") ComboBox1.Items.Add("SALEM") ComboBox1.Items.Add("VAIGAI") End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged If ComboBox1.SelectedIndex = 0 And NumericUpDown1.Value = 1 Then TextBox1.Text = "10.50" TextBox2.Text = "CHENNAI" TextBox3.Text = "MADURAI" End If If ComboBox1.SelectedIndex = 1 And NumericUpDown1.Value = 2 Then TextBox1.Text = "12.50" TextBox2.Text = "CHENNAI" TextBox3.Text = "THANJAVUR" End If If ComboBox1.SelectedIndex = 2 And NumericUpDown1.Value = 3 Then TextBox1.Text = "16.30" TextBox2.Text = "CHENNAI" TextBox3.Text = "MUMBAI"
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
End If If ComboBox1.SelectedIndex = 3 And NumericUpDown1.Value = 4 Then TextBox1.Text = "18.10" TextBox2.Text = "CHENNAI" TextBox3.Text = "SALEM" End If If ComboBox1.SelectedIndex = 4 And NumericUpDown1.Value = 5 Then TextBox1.Text = "21.50" TextBox2.Text = "CHENNAI" TextBox3.Text = "GINGEE" End If End SubEnd Class
CLASS: 8
Project: 1
‘Eg for Web Browser, Tool Strip box
Form Design:
Legends:
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Form Coding:Public Class Form1
Private Sub ToolStripLabel1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel1.Click WebBrowser1.GoBack() End Sub
Private Sub ToolStripLabel5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel5.Click Try WebBrowser1.Url = New Uri(ToolStripComboBox1.Text) Timer1.Enabled = True Catch MsgBox("One possible problem is that the address does not begin with http://") End Try End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ToolStripComboBox1.Focus() End Sub
Private Sub ToolStripLabel2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel2.Click WebBrowser1.GoForward() End Sub
Private Sub ToolStripLabel3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel3.Click WebBrowser1.GoHome() End Sub
Private Sub ToolStripLabel4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel4.Click WebBrowser1.Refresh() End Sub
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick On Error GoTo a ToolStripProgressBar1.Value = ToolStripProgressBar1.Value + 1 If ToolStripProgressBar1.Value = 100 Then ToolStripProgressBar1.Value = 1 Timer1.Enabled = False End Ifa: End Sub
End Class
Project: 2
‘Eg for Tab Control
Form Design:
Legends:
Form Coding:THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.PictureBox1.Image = Global.Windows_2.My.Resources.Resources.image1 Me.PictureBox2.Image = Global.Windows_2.My.Resources.Resources.image2 Me.PictureBox3.Image = Global.Windows_2.My.Resources.Resources.image3 Me.PictureBox4.Image = Global.Windows_2.My.Resources.Resources.image4 Me.PictureBox5.Image = Global.Windows_2.My.Resources.Resources.image5 End Sub
End Class
Project: 3
‘Eg for Tree View Control
Form Design:
Legends:
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Form Coding:Public Class Form1 Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
TextBox1.Text = e.Node.Text
If e.Node.Text = "Bike 1" Then PictureBox1.Image = Global.Windows_3.My.Resources.b1 End If
If e.Node.Text = "Bike 2" Then PictureBox1.Image = Global.Windows_3.My.Resources.b2 End If
If e.Node.Text = "Bike 3" Then PictureBox1.Image = Global.Windows_3.My.Resources.b3 End If
If e.Node.Text = "Car 1" Then PictureBox1.Image = Global.Windows_3.My.Resources.c1 End If
If e.Node.Text = "Car 2" Then PictureBox1.Image = Global.Windows_3.My.Resources.c2 End If
If e.Node.Text = "Car 3" Then PictureBox1.Image = Global.Windows_3.My.Resources.c3 End If
If e.Node.Text = "Wallpaper 1" Then PictureBox1.Image = Global.Windows_3.My.Resources.w1 End If
If e.Node.Text = "Wallpaper 2" Then PictureBox1.Image = Global.Windows_3.My.Resources.w2 End If
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
If e.Node.Text = "Wallpaper 3" Then PictureBox1.Image = Global.Windows_3.My.Resources.w3 End If End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TreeView1.CheckBoxes = True End Sub
End Class
Project: 4
‘Eg for List View
Form Design:
Legends:
Form Coding:Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ComboBox1.Items.Add("Large Icon View") ComboBox1.Items.Add("Small Icon View") ComboBox1.Items.Add("List View") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ListView1.CheckBoxes = True End Sub
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ListView1.Items.Remove(ListView1.SelectedItems(0)) End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged If ComboBox1.SelectedIndex = 0 Then ListView1.View = View.LargeIcon ElseIf ComboBox1.SelectedIndex = 1 Then ListView1.View = View.SmallIcon Else ListView1.View = View.List End If End SubEnd Class
Project: 5
‘Eg for Checked List Box
Form Design:
Legends:
Form Coding:THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load CheckedListBox1.Items.Add("MDCA") CheckedListBox1.Items.Add("MDIT") CheckedListBox1.Items.Add("HCDA") CheckedListBox1.Items.Add("MULTIMEDIA") CheckedListBox1.Items.Add("HADWARE")
End SubEnd Class
CLASS: 9
Project: 1 ‘E.g. for data grid view, Data Set, Data Grid View, Binding Source control & to see Table values in Grid View Control without using codingForm Design:
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Legends:
Form1.text=VIEW ALL DETAILS
Form1.Startup=Center Screen
Project: 2 ‘To see Table values in Grid View Control by using codingForm Design:
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Form Coding:Imports System.Data.SqlClientPublic Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim cn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=F:\VB Dot Net\ADO Dot Net Notes\Class 1\Airtel Customer Details\Airtel Customer Details\Database\db1.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True") cn.Open() MsgBox("Connection success") Dim cm As New SqlCommand("select*from details", cn) MsgBox("Table success") Dim ad As New SqlDataAdapter(cm) Dim ds As New DataSet ad.Fill(ds, "details") DataGridView1.DataSource = ds.Tables("details") End SubEnd Class
CLASS: 10
Project: 1
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
‘Eg for Menu StripForm Design:
Form Coding:Public Class Form1 Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click End End Sub Private Sub ToolStripMenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem3.Click PictureBox1.Image = My.Resources.w1 End Sub Private Sub ToolStripMenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem4.Click PictureBox1.Image = My.Resources.w2 End Sub Private Sub ToolStripMenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem5.Click PictureBox1.Image = My.Resources.w3 End SubEnd Class
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click End End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim i As Image PictureBox1.Image = i End Sub
Private Sub Button1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.MouseEnter ToolTip1.SetToolTip(Button1, "Click Here to Load Image") ToolTip1.InitialDelay = 5 ToolTip1.ReshowDelay = 110 End Sub
Private Sub Button2_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.MouseEnter ToolTip1.SetToolTip(Button2, "Click Here to Clear Image") ToolTip1.InitialDelay = 5 ToolTip1.ReshowDelay = 110 End Sub
Private Sub Button3_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.MouseEnter ToolTip1.SetToolTip(Button3, "Click Here to Quit") ToolTip1.InitialDelay = 5 ToolTip1.ReshowDelay = 110 End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click OpenFileDialog1.ShowDialog() PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName) PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage End SubEnd Class
CLASS: 11
Project: 1THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
‘Eg for Open, Save, Browser, Font, Color Dialog
Form Design:
Form Coding:
Imports System.Collections.ObjectModelPublic Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click RichTextBox1.Text = "" End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click OpenFileDialog1.ShowDialog() RichTextBox1.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName) MsgBox("Data Opened") End Sub
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click SaveFileDialog1.Filter = "TXT Files (*.txt*)|*.txt*" SaveFileDialog1.ShowDialog() My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, RichTextBox1.Text, True) MsgBox("Data Saved") End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click End End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click FolderBrowserDialog1.ShowDialog() TextBox1.Text = FolderBrowserDialog1.SelectedPath MsgBox("see your directory in textbox") End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click FontDialog1.ShowDialog() RichTextBox1.Font = FontDialog1.Font End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click ColorDialog1.ShowDialog() RichTextBox1.ForeColor = ColorDialog1.Color End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click ColorDialog1.ShowDialog() RichTextBox1.BackColor = ColorDialog1.Color End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click Dim files As ReadOnlyCollection(Of String) files = My.Computer.FileSystem.GetFiles(TextBox1.Text) ComboBox1.DataSource = files End SubEnd Class
CLASS: 12
Project: 1THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
‘Eg for Page Setup, Print Dialogue, Print Document, Print view Control Print View Dialog Form Design:
Form Coding:Imports System.Collections.ObjectModelPublic Class Form1 Dim pagenumber As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click RichTextBox1.Text = "" End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click OpenFileDialog1.ShowDialog() RichTextBox1.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName) MsgBox("Data Opened") End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click SaveFileDialog1.Filter = "TXT Files (*.txt*)|*.txt*" SaveFileDialog1.ShowDialog() My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, RichTextBox1.Text, True) MsgBox("Data Saved") End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click PageSetupDialog1.Document = PrintDocument1 PageSetupDialog1.PrinterSettings = PrintDocument1.PrinterSettings
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
PageSetupDialog1.PageSettings = PrintDocument1.DefaultPageSettings PageSetupDialog1.ShowDialog() PrintDocument1.PrinterSettings = PageSetupDialog1.PrinterSettings PrintDocument1.DefaultPageSettings = PageSetupDialog1.PageSettings End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click PrintDialog1.Document = PrintDocument1 PrintDialog1.PrinterSettings = PrintDocument1.PrinterSettings PrintDialog1.AllowSomePages = True PrintDialog1.ShowDialog() PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings PrintDocument1.Print() End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click PrintDocument1.Print() End Sub Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage pagenumber += 1 Select Case PageNumber Case 1
e.Graphics.FillRectangle(Brushes.Red, _ New Rectangle(200, 200, 500, 500)) e.HasMorePages = True Case 2 e.Graphics.FillRectangle(Brushes.Blue, _ New Rectangle(200, 200, 500, 500)) e.HasMorePages = False End Select End Sub Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click End End Sub Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click PrintPreviewDialog1.Document = PrintDocument1 PrintPreviewDialog1.ShowDialog() End SubEnd Class
CLASS: 13
Project: 1
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
‘Eg for Trackbar, Image List Form Design:
Form Coding:Public Class Form1 Dim I As Integer = 0 Dim J As Integer = 6 Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Timer1.Enabled = False End Sub
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Timer1.Interval = CInt(TextBox1.Text) Timer1.Enabled = True End Sub
Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll TextBox1.Text = TrackBar1.Value End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If I < 6 Then PictureBox1.Image = ImageList1.Images(I) I = I + 1 End If If I = 6 Then I = 0 End If End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If I < 6 Then PictureBox1.Image = ImageList1.Images(I) I = I + 1 End If If I = 6 Then I = 0 End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If J > 0 Then PictureBox1.Image = ImageList1.Images(J) J = J - 1 End If If J = 0 Then J = 6 End If
End SubEnd Class
Project: 2 ‘Eg for Windows Media Player
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Form Design:
Form Coding:Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click OpenFileDialog1.ShowDialog() AxWindowsMediaPlayer1.URL = OpenFileDialog1.FileName End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load OpenFileDialog1.Filter = "Videos files (*.avi)|*.avi|All files (*.*)|*.*" End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click AxWindowsMediaPlayer1.close() End Sub End Class
CLASS: 14 PROJECT: 1
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
‘My Computer Object
Form Design:
Form Coding:Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TextBox1.Text = My.Computer.Name.ToString TextBox2.Text = My.Computer.Clock.LocalTime.Now TextBox3.Text = My.Computer.Info.AvailablePhysicalMemory TextBox4.Text = My.Computer.Info.OSFullName TextBox5.Text = My.Computer.Info.OSVersion TextBox6.Text = My.Computer.FileSystem.Drives.ToString
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click My.Computer.Audio.Play("C:\WINDOWS\Media\chimes.wav", AudioPlayMode.BackgroundLoop) Button2.Enabled = False Button3.Enabled = True
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click My.Computer.Audio.Stop() Button2.Enabled = True Button3.Enabled = False End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click If (My.Computer.Keyboard.CapsLock = True) Then MsgBox("The CAPS LOCK key is on") Else MsgBox("The CAPS LOCK is Off") End If End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click If (My.Computer.Mouse.ButtonsSwapped) Then MsgBox("Functionalities of the mouse buttons have been swapped") Else MsgBox("The mouse is working fine") End If End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Dim i As Integer For i = 0 To My.Computer.Ports.SerialPortNames.Count - 1 MsgBox(My.Computer.Ports.SerialPortNames.Item(i)) Next End SubEnd Class
Legends:
PROJECT: 2
‘My User Object
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Form Design:
Form Coding:Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim domainname, username, fullname As String, i As Integer fullname = My.User.Name i = fullname.IndexOf("\") domainname = fullname.Substring(0, i) username = fullname.Substring(i + 1) MsgBox("Domain name : " & domainname & Chr(13) & _ "User name : " & username) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If My.User.IsAuthenticated Then MsgBox("You are authenticated to delete the file.") My.Computer.FileSystem.DeleteFile("c:\My\mytext.txt") Else MsgBox("Sorry, you are not authenticated to " _ & "delete the file") End If End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If My.User.IsInRole(ApplicationServices.BuiltInRole.Administrator) Then MsgBox("Current user is an Administrator") ElseIf My.User.IsInRole(ApplicationServices.BuiltInRole.Guest) Then MsgBox("Current user is a Guest") ElseIf My.User.IsInRole(ApplicationServices.BuiltInRole.User) Then MsgBox("Current user is a User") End If End SubEnd Class
CLASS: 15 PROJECT: 1
‘Cryptography ConceptTHANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Form Design:
Form Coding: Imports System.Security.CryptographyImports System.TextPublic Class Form1 Private publicKey, privatekey As String
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Private EncryptedStrAsByt() As Byte Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Button2.Enabled = False Button3.Enabled = False Button5.Enabled = False Button6.Enabled = False End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim cspParam As New CspParameters() cspParam.Flags = CspProviderFlags.UseMachineKeyStore Dim RSA As New RSACryptoServiceProvider(cspParam) publicKey = RSA.ToXmlString(True) ' gets the public key TextBox2.Text = publicKey.ToString() Button2.Enabled = True End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim str As String = TextBox1.Text Dim RSA2 As New RSACryptoServiceProvider() ' Load the public key to Encrypt Data RSA2.FromXmlString(publicKey) 'Start Encrypting Data EncryptedStrAsByt = RSA2.Encrypt(Encoding.UTF8.GetBytes(str), False) Dim EncryptedStrAsString As Object = Encoding.UTF8.GetString(EncryptedStrAsByt) 'Display Encrypted Data TextBox3.Text = EncryptedStrAsString.ToString() Button3.Enabled = True End Sub
Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 'Start Decrypting Data Dim RSA3 As New RSACryptoServiceProvider() RSA3.FromXmlString(publicKey) Dim DecryptedStrAsByt() As Byte = RSA3.Decrypt(EncryptedStrAsByt, False) Dim DecryptedStrAsString As Object = Encoding.UTF8.GetString(DecryptedStrAsByt) 'Display Decrypted Data TextBox4.Text = DecryptedStrAsString.ToString() End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim cspParam As New CspParameters() cspParam.Flags = CspProviderFlags.UseMachineKeyStore Dim RSA As New RSACryptoServiceProvider(cspParam) privateKey = RSA.ToXmlString(True) ' gets the private key TextBox6.Text = privatekey.ToString()
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Button5.Enabled = True End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Dim str As String = TextBox5.Text Dim RSA2 As New RSACryptoServiceProvider() ' Load the private key to Encrypt Data RSA2.FromXmlString(privatekey) 'Start Encrypting Data EncryptedStrAsByt = RSA2.Encrypt(Encoding.UTF8.GetBytes(str), False) Dim EncryptedStrAsString As Object = Encoding.UTF8.GetString(EncryptedStrAsByt) 'Display Encrypted Data TextBox7.Text = EncryptedStrAsString.ToString() Button6.Enabled = True End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click 'Start Decrypting Data Dim RSA3 As New RSACryptoServiceProvider() RSA3.FromXmlString(privatekey) Dim DecryptedStrAsByt() As Byte = RSA3.Decrypt(EncryptedStrAsByt, False) Dim DecryptedStrAsString As Object = Encoding.UTF8.GetString(DecryptedStrAsByt) 'Display Decrypted Data TextBox8.Text = DecryptedStrAsString.ToString() End SubEnd Class
PROJECT: 2
‘Cryptography Concept in Total File
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Form Design:
Form Coding: Imports System.TextImports System.IOImports System.SecurityImports System.Security.CryptographyImports System.Runtime.InteropServices
Public Class Form1
'<DllImport("KERNEL32.DLL", EntryPoint:="RtlZeroMemory")>Dim Public Shared ZeroMemory( Destination As IntPtr, Length As Integer) As Boolean
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load button3.Enabled = False End Sub
Private Sub textBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles textBox1.TextChanged If button3.Enabled = False Then toolStripStatusLabel1.Text = "Please specify an input file to encrypt." Else toolStripStatusLabel1.Text = "Please specify an input file to decrypt." End If End Sub
Private Sub textBox2_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles textBox2.TextChanged If button3.Enabled = False Then toolStripStatusLabel1.Text = "Output file path specified. Press the Encrypt File button for encrypting the file." Else
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
toolStripStatusLabel1.Text = "Output file path specified. Press the Decrypt File button for decrypting the file." End If End Sub
Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click OpenFileDialog1.Filter = "txt files (*.txt)|*.txt"
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then textBox1.Text = OpenFileDialog1.FileName.ToString() toolStripStatusLabel1.Text = "Input file selected.Specify the path for the output file." End If End Sub
Shared Function GenerateSecretKey() As String ' Create an object of the symmetric algorithm. A default secret key and IV are generated. Dim desCrypto As DESCryptoServiceProvider = CType(DESCryptoServiceProvider.Create(), DESCryptoServiceProvider)
' Return the default key Return ASCIIEncoding.ASCII.GetString(desCrypto.Key) End Function
Private Sub button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button2.Click Dim MySecretKey As String ' Get the secret key for encryption MySecretKey = GenerateSecretKey() label4.Text = MySecretKey ' For additional security, pin the key Dim gch As GCHandle = GCHandle.Alloc(MySecretKey, GCHandleType.Pinned) ' Encrypt the input file with the default secret key EncryptFile(textBox1.Text, textBox2.Text, MySecretKey) button3.Enabled = True toolStripStatusLabel1.Text = "Specify the input file to be decrypted." End Sub
Shared Sub EncryptFile(ByVal sInputFilename As String, ByVal sOutputFilename As String, ByVal sKey As String) 'Open the input file Dim FileStreamInputContainer As New FileStream(sInputFilename, FileMode.Open, FileAccess.Read) 'Start encrypting the file Dim fsEncrypted As New FileStream(sOutputFilename, FileMode.Create, FileAccess.Write) Dim DES As New DESCryptoServiceProvider() 'A 64-bit key and IV are required for the DES algorithm 'Set secret key for the DES algorithm DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey) 'Set the IV for the DES algorithm DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey)
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Dim desencrypt As ICryptoTransform = DES.CreateEncryptor() Dim cryptostream As New CryptoStream(fsEncrypted, desencrypt, CryptoStreamMode.Write)
Dim bytearrayinput(FileStreamInputContainer.Length - 1) As Byte FileStreamInputContainer.Read(bytearrayinput, 0, bytearrayinput.Length) cryptostream.Write(bytearrayinput, 0, bytearrayinput.Length) cryptostream.Close() FileStreamInputContainer.Close() fsEncrypted.Close() End Sub
Private Sub button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button3.Click Dim MySecretKey As String ' Get the secret key for decrypting the file MySecretKey = label4.Text DecryptFile(textBox1.Text, textBox2.Text, MySecretKey) End Sub
Shared Sub DecryptFile(ByVal sInputFilename As String, ByVal sOutputFilename As String, ByVal sKey As String) Dim DES As New DESCryptoServiceProvider() DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey) DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey)
'Create a file stream to read the decrypted file Dim fsread As New FileStream(sInputFilename, FileMode.Open, FileAccess.Read) 'Create a DES decryptor object for the current DES object Dim desdecrypt As ICryptoTransform = DES.CreateDecryptor() 'Create a crypto stream to read and do a 'DES decryption transform on incoming bytes Dim cryptostreamDecr As New CryptoStream(fsread, desdecrypt, CryptoStreamMode.Read) 'Store the decrypted data in the given output file Dim fsDecrypted As New StreamWriter(sOutputFilename) fsDecrypted.Write(New StreamReader(cryptostreamDecr).ReadToEnd()) fsDecrypted.Flush() fsDecrypted.Close() End SubEnd Class
CLASS: 16 PROJECT: 1
‘Airtel Customer details
Form 1:
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
‘Eg for Pointer, Label, Button
Form Design:
Form Coding:Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If TextBox1.Text = "karthi" AndAlso TextBox2.Text = "bss" Then MsgBox("login success") Dim f2 As New Form2 f2.Show() Me.Hide() Else MsgBox("login failed") TextBox1.Focus() End If End SubEnd Class
Legends:Label1.Text=”Enter the Username:”
Label2.Text=”Enter the Password:”
Textbox2.password Char=*
Button1.text=LOGIN!!!
Form1.Border Style= Fixed Tool Window
Form 2:
‘EG Progress bar, Timer Control
Form Design:
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Form Coding:Public Class Form2 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick On Error GoTo a ProgressBar1.Value = ProgressBar1.Value + 1 Label1.Text = "Loading Complete.." & ProgressBar1.Value & "%" If ProgressBar1.Value = 100 Then MsgBox("Loading completed") Timer1.Enabled = False Dim f3 As New Form3 f3.Show() Me.Hide()a: End If End SubEnd Class
LEGENDS:
Timer1.Enabled=true
Timer1.interval=100
Form2.text=Please Wait..
Label1.Text=Loading..
Form2.Controlbox=false
Form 3:
‘EG MDI, Group Box
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
FORM DESIGN:
Form Coding:Public Class Form3 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim f4 As New Form4 f4.Show() End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim f5 As New Form5 f5.Show() End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click End End Sub
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Label2.Text = "DATE:" & DateValue(Now) Label3.Text = "TIME:" & TimeOfDay End SubEnd Class
LEGENDS:
FORM 4:
‘EG Mask Text, Date and Time Picker
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
FORM DESIGN:
Form Coding:Public Class Form4
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim f3 As New Form3 f3.Show() Me.Hide() End SubEnd Class
LEGENDS:
Form 5:
THANKING YOU
CREATED BY A.KARTHIKEYAN
VB .NET 2008
‘EG Data Grid ViewFORM DESIGN:
Form Coding:Public Class Form5
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim f3 As New Form3 f3.Show() Me.Hide() End SubEnd Class