SlideShare une entreprise Scribd logo
1  sur  19
Télécharger pour lire hors ligne
VB.Net Programs
Prof. K. Adisesha 1
C# & Dot Net Lab Programs
Part- B
1. VB.net Program to count the number of Vowels in a string
Public Class Form1
Private Sub resultBtn_Click(sender As Object, e As EventArgs) Handles resultBtn.Click
Dim str1, str2 As String
Dim vcount, i, str1len As Integer
vcount = 0
str1 = stringText.Text
str1len = Len(str1)
str1 = LCase(str1)
For i = 1 To str1len
str2 = Mid(str1, i, 1)
If str2 = "a" Or str2 = "e" Or str2 = "i" Or str2 = "o" Or str2 = "u" Then
vcount = vcount + 1
End If
Next i
resultText.Text = vcount
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Close()
End Sub
End Class
VB.Net Programs
Prof. K. Adisesha 2
Output:
VB.Net Programs
Prof. K. Adisesha 3
2. VB.net Program to Check a given is Even or Odd Number or Overflow
if number>10000
Code:
Public Class Form1
Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles resultBtn.Click
If valueText.Text Mod 2 = 0 Then
resultText.Text = "EVEN"
Else
resultText.Text = "ODD"
End If
If valueText.Text > 10000 Then
resultText.Text = "Overflow!!!"
End If
VB.Net Programs
Prof. K. Adisesha 4
End Sub
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
valueText.Text = ""
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Close()
End Sub
End Class
Output:
VB.Net Programs
Prof. K. Adisesha 5
3. VB.net Program to calculate the compound interest
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles resultBtn.Click
Dim P As Integer
Dim R As Integer
Dim n As Integer
P = principleText.Text
R = rateText.Text
n = timeText.Text
compText.Text = P * (1 + (R / 100)) ^ n - 1
End Sub
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles btnExit.Click
Close()
End Sub
VB.Net Programs
Prof. K. Adisesha 6
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
principleText.Text = ""
rateText.Text = ""
timeText.Text = ""
End Sub
End Class
Output:
VB.Net Programs
Prof. K. Adisesha 7
4. VB.Net Program to Display the sum of Positive and negative numbers
using input box
Code:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub resultBtn_Click(sender As Object, e As EventArgs) Handles resultBtn.Click
Dim arr(), a, b, c, i As Integer
a = CInt(limitText.Text)
ReDim arr(a)
For i = 0 To a - 1 Step 1
arr(i) = CInt(InputBox("Enter elements:"))
If arr(i) > 0 Then
b = b + arr(i)
ElseIf arr(i) < 0 Then
c = c + arr(i)
End If
Next
positiveText.Text = b
negativeText.Text = c
End Sub
VB.Net Programs
Prof. K. Adisesha 8
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Close()
End Sub
End Class
Output:
VB.Net Programs
Prof. K. Adisesha 9
5. VB.Net Program to concatenate two strings and display result using
Message Box.
Code:
Public Class Form1
Private Sub resultBtn_Click(sender As Object, e As EventArgs) Handles resultBtn.Click
Dim x As String
Dim y As String
x = firstText.Text
y = lastText.Text
MsgBox(firstText.Text + " " + lastText.Text, vbOKCancel)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Close()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles btnclear.Click
firstText.Clear()
lastText.Clear()
End Sub
End Class
VB.Net Programs
Prof. K. Adisesha 10
Output:
VB.Net Programs
Prof. K. Adisesha 11
6. Write a program to change the style of font based on the user’s
choice by using CHECK BOX BUTTON
Public Class Form1
Private Sub setStyle()
Dim style = FontStyle.Regular
If boldCheck.Checked Then
style = style Or FontStyle.Bold
End If
If italicsCheck.Checked Then
style = style Or FontStyle.Italic
End If
If underLineCheck.Checked Then
style = style Or FontStyle.Underline
End If
inputText.Font = New Font(inputText.Font, style)
End Sub
Private Sub boldCheck_CheckedChanged(sender As Object, e As EventArgs) Handles
boldCheck.CheckedChanged
setStyle()
End Sub
Private Sub italicsCheck_CheckedChanged(sender As Object, e As EventArgs) Handles
italicsCheck.CheckedChanged
VB.Net Programs
Prof. K. Adisesha 12
setStyle()
End Sub
Private Sub underLineCheck_CheckedChanged(sender As Object, e As EventArgs)
Handles underLineCheck.CheckedChanged
setStyle()
End Sub
End Class
Output:
VB.Net Programs
Prof. K. Adisesha 13
7. Write a program to generate a Student Enrolment Details form using
Combo box.
Code:
Public Class Form1
Private Sub dispBtn_Click(sender As Object, e As EventArgs) Handles dispBtn.Click
MsgBox("These are the following details entered: " + vbCrLf + " Name:" + nameText.Text + vbCrLf
+ "Course:" + courseCombo.Text + vbCrLf + "Semester:" + semCombo.Text + vbCrLf + "Marks:" +
marksText.Text, vbOKOnly)
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Close()
End Sub
End Class
VB.Net Programs
Prof. K. Adisesha 14
Output:
VB.Net Programs
Prof. K. Adisesha 15
8. Write a program to generate a Dynamic User login form using
Database.
Code:
Note: Follow the following steps:
➢ Provide MySQL password
➢ Create a Database and provide DB name in Inputbox.
➢ Login table will be created with the given Name in Inputbox
Imports System.Data.Odbc
Public Class Form1
Dim uname As String = InputBox("Enter the UserName of MySql:")
Dim pass As String = InputBox("Enter the password of MySql:")
Dim dB As String = InputBox("Enter the DataBase name")
Dim connectionString As String = "DRIVER={MySQL ODBC 8.0 Unicode
Driver};SERVER=localhost;DATABASE=" + dB + ";UID=" + uname + ";PASSWORD=" + pass
+ ";OPTION=3;"
Public conn As New OdbcConnection(connectionString)
Dim sqlTableCreate As String = "CREATE TABLE users(username varchar(25),password
varchar(25));"
Dim cmdCreate As New OdbcCommand(sqlTableCreate, conn)
VB.Net Programs
Prof. K. Adisesha 16
Sub Open()
cmdCreate.ExecuteNonQuery()
End Sub
Private Sub createBtn_Click(sender As Object, e As EventArgs) Handles createBtn.Click
Try
If unameText.Text = "" Or passText.Text = "" Then
MsgBox("Please Provide the values", vbExclamation)
Else
conn.Open()
Dim rows As Integer
Dim sqlInsert As String = "INSERT INTO users(username,password) values(" + "'"
+ unameText.Text + "','" + passText.Text + "')"
Dim cmd As New OdbcCommand(sqlInsert, conn)
rows = cmd.ExecuteNonQuery()
If rows > 0 Then
MsgBox("User Created!", vbOK)
End If
End If
conn.Close()
Catch ex As Exception
MsgBox("Database Error", vbExclamation)
End Try
End Sub
Private Sub loginBtn_Click(sender As Object, e As EventArgs) Handles loginBtn.Click
Try
conn.Open()
Dim sqlSelect As String = "SELECT username,password FROM users WHERE
username=" + "'" + unameText.Text + "' AND " + "password='" + passText.Text + "'"
Dim cmd As New OdbcCommand(sqlSelect, conn)
Dim sqlResult As OdbcDataReader
sqlResult = cmd.ExecuteReader()
If sqlResult.HasRows Then
MsgBox("User Successfully Logged In", vbOK)
conn.Close()
Else
MsgBox("No Match found", vbExclamation)
conn.Close()
End If
Catch ex As Exception
MsgBox("DataBase Error", vbCritical)
End Try
VB.Net Programs
Prof. K. Adisesha 17
End Sub
Private Sub clearBtn_Click(sender As Object, e As EventArgs) Handles clearBtn.Click
unameText.Clear()
passText.Clear()
End Sub
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles
showPassCheck.CheckedChanged
If showPassCheck.CheckState = CheckState.Unchecked Then
passText.PasswordChar = "*"
ElseIf showPassCheck.CheckState = CheckState.Checked Then
passText.PasswordChar = ""
End If
End Sub
End Class
Output:
VB.Net Programs
Prof. K. Adisesha 18
9. Program to Implement MDI (Multiple Document Interface) Parent Form
Follow the following Steps
➢ To make a form as MDI Form set its IsMdiContainer property as true.
➢ To define a parent form to a child form set MdiParent property.
➢ To arrange the child forms, use LayoutMdi() method.
➢ To get reference of the current child form use ActiveMdiChild property.
➢ To get reference of a control from the child form use its Controls collection.
Output:
VB.Net Programs
Prof. K. Adisesha 19

Contenu connexe

Tendances (20)

Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
 
Database connectivity in python
Database connectivity in pythonDatabase connectivity in python
Database connectivity in python
 
android menus
android menusandroid menus
android menus
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
parameter passing in c#
parameter passing in c#parameter passing in c#
parameter passing in c#
 
C# Lab Programs.pdf
C# Lab Programs.pdfC# Lab Programs.pdf
C# Lab Programs.pdf
 
Use Case Diagram
Use Case DiagramUse Case Diagram
Use Case Diagram
 
Understanding Subroutines and Functions in VB6
Understanding Subroutines and Functions in VB6Understanding Subroutines and Functions in VB6
Understanding Subroutines and Functions in VB6
 
Applets in java
Applets in javaApplets in java
Applets in java
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in android
 
Awt controls ppt
Awt controls pptAwt controls ppt
Awt controls ppt
 
JavaScript Conditional Statements
JavaScript Conditional StatementsJavaScript Conditional Statements
JavaScript Conditional Statements
 
Javascript essentials
Javascript essentialsJavascript essentials
Javascript essentials
 
Presentation of awk
Presentation of awkPresentation of awk
Presentation of awk
 
Visual Programming
Visual ProgrammingVisual Programming
Visual Programming
 
VB Function and procedure
VB Function and procedureVB Function and procedure
VB Function and procedure
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
PHP - Introduction to File Handling with PHP
PHP -  Introduction to  File Handling with PHPPHP -  Introduction to  File Handling with PHP
PHP - Introduction to File Handling with PHP
 
Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
 
VB Script
VB ScriptVB Script
VB Script
 

Similaire à VB net lab.pdf

VISUAL BASIC PRATICAL FILE MSC COMPUTER SCIENCE.pdf
VISUAL BASIC PRATICAL FILE MSC COMPUTER SCIENCE.pdfVISUAL BASIC PRATICAL FILE MSC COMPUTER SCIENCE.pdf
VISUAL BASIC PRATICAL FILE MSC COMPUTER SCIENCE.pdfBALWANSAINI1
 
Inventory management
Inventory managementInventory management
Inventory managementRajeev Sharan
 
LoginFormCode
LoginFormCodeLoginFormCode
LoginFormCoderk5media
 
Membuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhanaMembuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhanaYusman Kurniadi
 
Ensayo Convergencia Informatica
Ensayo Convergencia InformaticaEnsayo Convergencia Informatica
Ensayo Convergencia Informaticamiguel camelo
 
Puerto serialarduino
Puerto serialarduinoPuerto serialarduino
Puerto serialarduinozadkiel_123
 
4.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.15
4.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.154.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.15
4.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.15Rajes Wari
 
I can't get my code below to work with Option Strict On due to this part of t...
I can't get my code below to work with Option Strict On due to this part of t...I can't get my code below to work with Option Strict On due to this part of t...
I can't get my code below to work with Option Strict On due to this part of t...hwbloom115
 
Lecture 09 high level language
Lecture 09 high level languageLecture 09 high level language
Lecture 09 high level language鍾誠 陳鍾誠
 
SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)Darwin Durand
 
Updated Visual Basic 6 for beginners.pptx
Updated Visual Basic 6 for beginners.pptxUpdated Visual Basic 6 for beginners.pptx
Updated Visual Basic 6 for beginners.pptxSarveshDeodhar
 
1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docx1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docxcorbing9ttj
 
1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docx1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docxcorbing9ttj
 
Kajal Gaharwal , BCA Third Year
Kajal Gaharwal , BCA Third YearKajal Gaharwal , BCA Third Year
Kajal Gaharwal , BCA Third YearDezyneecole
 
.Net Enterprise Services and their Implementations
.Net Enterprise Services and their Implementations.Net Enterprise Services and their Implementations
.Net Enterprise Services and their ImplementationsKashif Aleem
 

Similaire à VB net lab.pdf (20)

Docimp
DocimpDocimp
Docimp
 
VISUAL BASIC PRATICAL FILE MSC COMPUTER SCIENCE.pdf
VISUAL BASIC PRATICAL FILE MSC COMPUTER SCIENCE.pdfVISUAL BASIC PRATICAL FILE MSC COMPUTER SCIENCE.pdf
VISUAL BASIC PRATICAL FILE MSC COMPUTER SCIENCE.pdf
 
Inventory management
Inventory managementInventory management
Inventory management
 
LoginFormCode
LoginFormCodeLoginFormCode
LoginFormCode
 
Membuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhanaMembuat aplikasi penjualan buku sederhana
Membuat aplikasi penjualan buku sederhana
 
Ensayo Convergencia Informatica
Ensayo Convergencia InformaticaEnsayo Convergencia Informatica
Ensayo Convergencia Informatica
 
.net progrmming part4
.net progrmming part4.net progrmming part4
.net progrmming part4
 
Puerto serialarduino
Puerto serialarduinoPuerto serialarduino
Puerto serialarduino
 
Hems
HemsHems
Hems
 
4.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.15
4.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.154.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.15
4.7.14&amp;17.7.14&amp;23.6.15&amp;10.9.15
 
UtilityCostCalcCode
UtilityCostCalcCodeUtilityCostCalcCode
UtilityCostCalcCode
 
I can't get my code below to work with Option Strict On due to this part of t...
I can't get my code below to work with Option Strict On due to this part of t...I can't get my code below to work with Option Strict On due to this part of t...
I can't get my code below to work with Option Strict On due to this part of t...
 
Lecture 09 high level language
Lecture 09 high level languageLecture 09 high level language
Lecture 09 high level language
 
SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)
 
Ete programs
Ete programsEte programs
Ete programs
 
Updated Visual Basic 6 for beginners.pptx
Updated Visual Basic 6 for beginners.pptxUpdated Visual Basic 6 for beginners.pptx
Updated Visual Basic 6 for beginners.pptx
 
1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docx1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docx
 
1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docx1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docx
 
Kajal Gaharwal , BCA Third Year
Kajal Gaharwal , BCA Third YearKajal Gaharwal , BCA Third Year
Kajal Gaharwal , BCA Third Year
 
.Net Enterprise Services and their Implementations
.Net Enterprise Services and their Implementations.Net Enterprise Services and their Implementations
.Net Enterprise Services and their Implementations
 

Plus de Prof. Dr. K. Adisesha

Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfSoftware Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfSoftware Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfSoftware Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfProf. Dr. K. Adisesha
 
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfSoftware Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfProf. Dr. K. Adisesha
 
Computer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaComputer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaProf. Dr. K. Adisesha
 
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaCCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaProf. Dr. K. Adisesha
 
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaCCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaProf. Dr. K. Adisesha
 
CCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaCCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaProf. Dr. K. Adisesha
 
CCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfCCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfProf. Dr. K. Adisesha
 

Plus de Prof. Dr. K. Adisesha (20)

Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdf
 
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfSoftware Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdf
 
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfSoftware Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
 
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfSoftware Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
 
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfSoftware Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
 
Computer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaComputer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. Adisesha
 
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaCCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
 
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaCCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
 
CCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaCCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. Adisesha
 
CCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfCCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdf
 
Introduction to Computers.pdf
Introduction to Computers.pdfIntroduction to Computers.pdf
Introduction to Computers.pdf
 
R_Programming.pdf
R_Programming.pdfR_Programming.pdf
R_Programming.pdf
 
Scholarship.pdf
Scholarship.pdfScholarship.pdf
Scholarship.pdf
 
Operating System-2 by Adi.pdf
Operating System-2 by Adi.pdfOperating System-2 by Adi.pdf
Operating System-2 by Adi.pdf
 
Operating System-1 by Adi.pdf
Operating System-1 by Adi.pdfOperating System-1 by Adi.pdf
Operating System-1 by Adi.pdf
 
Operating System-adi.pdf
Operating System-adi.pdfOperating System-adi.pdf
Operating System-adi.pdf
 
Data_structure using C-Adi.pdf
Data_structure using C-Adi.pdfData_structure using C-Adi.pdf
Data_structure using C-Adi.pdf
 
JAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdfJAVA PPT -2 BY ADI.pdf
JAVA PPT -2 BY ADI.pdf
 
JAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdfJAVA PPT -5 BY ADI.pdf
JAVA PPT -5 BY ADI.pdf
 

Dernier

General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 

Dernier (20)

General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 

VB net lab.pdf

  • 1. VB.Net Programs Prof. K. Adisesha 1 C# & Dot Net Lab Programs Part- B 1. VB.net Program to count the number of Vowels in a string Public Class Form1 Private Sub resultBtn_Click(sender As Object, e As EventArgs) Handles resultBtn.Click Dim str1, str2 As String Dim vcount, i, str1len As Integer vcount = 0 str1 = stringText.Text str1len = Len(str1) str1 = LCase(str1) For i = 1 To str1len str2 = Mid(str1, i, 1) If str2 = "a" Or str2 = "e" Or str2 = "i" Or str2 = "o" Or str2 = "u" Then vcount = vcount + 1 End If Next i resultText.Text = vcount End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Close() End Sub End Class
  • 2. VB.Net Programs Prof. K. Adisesha 2 Output:
  • 3. VB.Net Programs Prof. K. Adisesha 3 2. VB.net Program to Check a given is Even or Odd Number or Overflow if number>10000 Code: Public Class Form1 Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles resultBtn.Click If valueText.Text Mod 2 = 0 Then resultText.Text = "EVEN" Else resultText.Text = "ODD" End If If valueText.Text > 10000 Then resultText.Text = "Overflow!!!" End If
  • 4. VB.Net Programs Prof. K. Adisesha 4 End Sub Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click valueText.Text = "" End Sub Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click Close() End Sub End Class Output:
  • 5. VB.Net Programs Prof. K. Adisesha 5 3. VB.net Program to calculate the compound interest Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles resultBtn.Click Dim P As Integer Dim R As Integer Dim n As Integer P = principleText.Text R = rateText.Text n = timeText.Text compText.Text = P * (1 + (R / 100)) ^ n - 1 End Sub Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles btnExit.Click Close() End Sub
  • 6. VB.Net Programs Prof. K. Adisesha 6 Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click principleText.Text = "" rateText.Text = "" timeText.Text = "" End Sub End Class Output:
  • 7. VB.Net Programs Prof. K. Adisesha 7 4. VB.Net Program to Display the sum of Positive and negative numbers using input box Code: Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub Private Sub resultBtn_Click(sender As Object, e As EventArgs) Handles resultBtn.Click Dim arr(), a, b, c, i As Integer a = CInt(limitText.Text) ReDim arr(a) For i = 0 To a - 1 Step 1 arr(i) = CInt(InputBox("Enter elements:")) If arr(i) > 0 Then b = b + arr(i) ElseIf arr(i) < 0 Then c = c + arr(i) End If Next positiveText.Text = b negativeText.Text = c End Sub
  • 8. VB.Net Programs Prof. K. Adisesha 8 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Close() End Sub End Class Output:
  • 9. VB.Net Programs Prof. K. Adisesha 9 5. VB.Net Program to concatenate two strings and display result using Message Box. Code: Public Class Form1 Private Sub resultBtn_Click(sender As Object, e As EventArgs) Handles resultBtn.Click Dim x As String Dim y As String x = firstText.Text y = lastText.Text MsgBox(firstText.Text + " " + lastText.Text, vbOKCancel) End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnExit.Click Close() End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles btnclear.Click firstText.Clear() lastText.Clear() End Sub End Class
  • 10. VB.Net Programs Prof. K. Adisesha 10 Output:
  • 11. VB.Net Programs Prof. K. Adisesha 11 6. Write a program to change the style of font based on the user’s choice by using CHECK BOX BUTTON Public Class Form1 Private Sub setStyle() Dim style = FontStyle.Regular If boldCheck.Checked Then style = style Or FontStyle.Bold End If If italicsCheck.Checked Then style = style Or FontStyle.Italic End If If underLineCheck.Checked Then style = style Or FontStyle.Underline End If inputText.Font = New Font(inputText.Font, style) End Sub Private Sub boldCheck_CheckedChanged(sender As Object, e As EventArgs) Handles boldCheck.CheckedChanged setStyle() End Sub Private Sub italicsCheck_CheckedChanged(sender As Object, e As EventArgs) Handles italicsCheck.CheckedChanged
  • 12. VB.Net Programs Prof. K. Adisesha 12 setStyle() End Sub Private Sub underLineCheck_CheckedChanged(sender As Object, e As EventArgs) Handles underLineCheck.CheckedChanged setStyle() End Sub End Class Output:
  • 13. VB.Net Programs Prof. K. Adisesha 13 7. Write a program to generate a Student Enrolment Details form using Combo box. Code: Public Class Form1 Private Sub dispBtn_Click(sender As Object, e As EventArgs) Handles dispBtn.Click MsgBox("These are the following details entered: " + vbCrLf + " Name:" + nameText.Text + vbCrLf + "Course:" + courseCombo.Text + vbCrLf + "Semester:" + semCombo.Text + vbCrLf + "Marks:" + marksText.Text, vbOKOnly) End Sub Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click Close() End Sub End Class
  • 14. VB.Net Programs Prof. K. Adisesha 14 Output:
  • 15. VB.Net Programs Prof. K. Adisesha 15 8. Write a program to generate a Dynamic User login form using Database. Code: Note: Follow the following steps: ➢ Provide MySQL password ➢ Create a Database and provide DB name in Inputbox. ➢ Login table will be created with the given Name in Inputbox Imports System.Data.Odbc Public Class Form1 Dim uname As String = InputBox("Enter the UserName of MySql:") Dim pass As String = InputBox("Enter the password of MySql:") Dim dB As String = InputBox("Enter the DataBase name") Dim connectionString As String = "DRIVER={MySQL ODBC 8.0 Unicode Driver};SERVER=localhost;DATABASE=" + dB + ";UID=" + uname + ";PASSWORD=" + pass + ";OPTION=3;" Public conn As New OdbcConnection(connectionString) Dim sqlTableCreate As String = "CREATE TABLE users(username varchar(25),password varchar(25));" Dim cmdCreate As New OdbcCommand(sqlTableCreate, conn)
  • 16. VB.Net Programs Prof. K. Adisesha 16 Sub Open() cmdCreate.ExecuteNonQuery() End Sub Private Sub createBtn_Click(sender As Object, e As EventArgs) Handles createBtn.Click Try If unameText.Text = "" Or passText.Text = "" Then MsgBox("Please Provide the values", vbExclamation) Else conn.Open() Dim rows As Integer Dim sqlInsert As String = "INSERT INTO users(username,password) values(" + "'" + unameText.Text + "','" + passText.Text + "')" Dim cmd As New OdbcCommand(sqlInsert, conn) rows = cmd.ExecuteNonQuery() If rows > 0 Then MsgBox("User Created!", vbOK) End If End If conn.Close() Catch ex As Exception MsgBox("Database Error", vbExclamation) End Try End Sub Private Sub loginBtn_Click(sender As Object, e As EventArgs) Handles loginBtn.Click Try conn.Open() Dim sqlSelect As String = "SELECT username,password FROM users WHERE username=" + "'" + unameText.Text + "' AND " + "password='" + passText.Text + "'" Dim cmd As New OdbcCommand(sqlSelect, conn) Dim sqlResult As OdbcDataReader sqlResult = cmd.ExecuteReader() If sqlResult.HasRows Then MsgBox("User Successfully Logged In", vbOK) conn.Close() Else MsgBox("No Match found", vbExclamation) conn.Close() End If Catch ex As Exception MsgBox("DataBase Error", vbCritical) End Try
  • 17. VB.Net Programs Prof. K. Adisesha 17 End Sub Private Sub clearBtn_Click(sender As Object, e As EventArgs) Handles clearBtn.Click unameText.Clear() passText.Clear() End Sub Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles showPassCheck.CheckedChanged If showPassCheck.CheckState = CheckState.Unchecked Then passText.PasswordChar = "*" ElseIf showPassCheck.CheckState = CheckState.Checked Then passText.PasswordChar = "" End If End Sub End Class Output:
  • 18. VB.Net Programs Prof. K. Adisesha 18 9. Program to Implement MDI (Multiple Document Interface) Parent Form Follow the following Steps ➢ To make a form as MDI Form set its IsMdiContainer property as true. ➢ To define a parent form to a child form set MdiParent property. ➢ To arrange the child forms, use LayoutMdi() method. ➢ To get reference of the current child form use ActiveMdiChild property. ➢ To get reference of a control from the child form use its Controls collection. Output: