Sunteți pe pagina 1din 79

AC PRACTICALS

PRACTICAL NO: 1
Create a website for an NGO. The website will have navigation page,
menu page & content page. The navigation will display logo & name
of the organization. The menu page will have three links. About us,
contact us, feedback.
CODE: Ngotop.html:
<html>
<head>
<title>Gunjan Jadhav Rollno.37</title>
</head>
<body>
<P>Gunjan Jadhav</P>
<img src="ngo.jpg" alt="logo" width="300" height="80">
<h1>Save Girl Child</h1>
</body>
</html>

Ngoau.html:
<html>
<head>
<title>about us</title>
</head>
<body>
<p><b>

About Us
The Organization for Eradication of illiteracy and Poverty seeks to awaken
the social consciousness of society towards its own ills. We are challenging
the formation of conscience in order to bring about a social change where
one lives in a classless and unbiased society. Dr. Bernard Malik is the Director
of this organization. He has strong belief in the basic goodness of human
beings. Human beings have a strong instinct to choose good over evil.
Therefore Dr. Malik believes education is the key to resolve the evils of the
society. The lack of education is the cause of many problems around.
Education provides freedom from illiteracy and poverty. Literacy serves as an
instrument of poverty alleviation. Therefore Dr. Bernard Malik founded the
Organization for Eradication of Illiteracy and Poverty. By this he seeks to
affect a worldwide campaign of educational empowerment.
</b></p>
</body>
</html>

Ngocu.html:
<html>
<head>
<title>contact us</title>
</head>
<body>
<p><pre><b>Contact Us:
1234567890
7896541230
0147852369</b></pre></p>
</body>
</html>

Ngofb.html:

<html>
<head>
<title>Feedback</title>
</head>
<body>
<form action="">
Name:<input type="text"><br>
Address:<input type="text"><br>
DOB:<input type="date"><br>
Contact No:<input type="text"><br>
Age:<input type="number"><br>
<input type="reset" value="reset">
<input type="submit" value="submit">
</form>
</body>
</html>

Ngomenu.html:
<html>
<head>
<title>Menu</title>
</head>
<body>
<a href="ngoau.html" target="right">About us</a><br>
<a href="ngocu.html" target="right">Contact us</a><br>
<a href="ngofb.html" target="right">Feedback</a>

</body>
</html>

Ngomain.html:
<html>
<title>
Gunjan Jadhav Rollno.37
</title>
<frameset rows="30%,70%">
<frame src="ngotop.html" name="top">
<frameset cols="20%,80%">
<frame src="ngomenu.html" name="left">
<frame src="ngoau.html" name="right">
</frameset>
</frameset>
</html>

Output:

PRACTICAL NO: 2
Create an html page which will display the
calendar for June 2016.

CODE:
<html>
<head>
<title>
Gunjan Jadhav Roll No.37
</title>
</head>
<body>
<p>Gunjan Jadhav</p>
<center>
<table border="2" width="50%" cellpadding="20" cellspacing="5"
style="text-align:center;">
<tr>
<td colspan="6">June 2016</td>
</tr>
<tr>
<td>Sun</td>
<td><img src="img1.jpg" height="10" width="10"/></td>
<td>5</td>

<td>12</td>
<td>19</td>
<td>26</td>
</tr>
<tr>
<td>Mon</td>
<td><img src="img2.jpg" height="10" width="10"/></td>
<td>6</td>
<td>13</td>
<td>10</td>
<td>27</td>
</tr>
<tr>
<td>Tue</td>
<td><img src="img3.jpg" height="10" width="10"/></td>
<td>7</td>
<td>14</td>
<td>21</td>
<td>28</td>
</tr>
<tr>
<td>Wed</td>
<td>1</td>
<td>8</td>
<td>15</td>

<td>22</td>
<td>29</td>
</tr>
<tr>
<td>Thru</td>
<td>2</td>
<td>9</td>
<td>16</td>
<td>23</td>
<td>30</td>
</tr>
<tr>
<td>Fri</td>
<td>3</td>
<td>10</td>
<td>17</td>
<td>24</td>
<td><img src="img4.jpg" height="10" width="10"/></td>
</tr>
<tr>
<td>Sat</td>
<td>4</td>
<td>11</td>
<td>18</td>
<td>25</td>

<td><img src="img5.jpg" height="10" width="10"/></td>


</tr>
</table>
</center>
</body>
</html>

Output:

PRACTICAL NO: 3
Create an html page for the purpose of admission form
accepts name, address, DOB, HSC marks, programming
languages, gender & languages. The form also includes
submit & cancel button.

CODE:
<html>
<head>
<title>Gunjan Jadhav Rollno.37</title>
</head>
<body>
<p>Gunjan Jadhav</p>
<center>
<table border="2" height="95%" width="50%" cellpadding="10"
cellspacing="5" style="text-align:center">
<tr>
<td colspan="6">Admission Form</td>
</tr>
<tr>
<td>Name</td>

<td><input type="text"></td>
</tr>
<tr>
<td>Address</td>
<td><textarea rows="5" colspan="10"></textarea></td>
</tr>
<tr>
<td>DOB:</td>
<td><input type="date"></td>
</tr>
<tr>
<td>HSC marks</td>
<td><input type="number"></td>
</tr>
<tr>
<td>Programing languages</td>
<td><input type="checkbox">C<input type="checkbox">C++<input
type="checkbox">Java</td>
</tr>
<tr>
<td>Gender</td>
<td><input type="radio">Male<input type="radio">Female</td>
</tr>
<tr>
<td>Language</td>

<td><Select
size="3"><option>Eng</option><option>Mar</option><option>Hin</opti
on></td>
</tr>
<tr>
<td></td>
<td><input type="button" value="Submit">
<input type="button" value="cancel"></td>
</tr>
</body>
</html>

Output:

PRACTICAL NO: 4
Create a homepage for High school using CSS elements &
Div tag with vertical & horizontal navigation bar.

CODE:
<html>
<head>
<title>Gunjan Jadhav Rollno.37</title>
<style>
div.d1{
width:100%;
height:30%;
border-style:dotted;
background-color:yellow;
}
div.d2{
width:29%;
height:60%;
border-style:solid;
background-color:pink;

float:left;
}
div.d3{
width:70%;
height:60%;
border-style:solid;
background-color:lightblue;
float:right;
}
ul
{
list-style-type:none;
margin:0;
padding:0;
border:1px solid black;
text-decoration:none;
}
li a{
display:block;
color:black;
padding:8px 16px;
text-decoration:none;
}
li{
text-align:center;

border-bottom:1px solid black;


}
li a:hover {
background-color:lightgray;
color:blue;
}
#d1 li{
display:inline;
color:black;
padding:5px 16px;
}
#d1 li a{
display:inline;
color:black;
padding:8px 16px;
}
#d1 li a:hover {
background-color:lightgray;
color:blue;
}
table tr,td{
border:1px solid black;
}
table{
border-collapse:collapse;

width:100%;
}
tr:nth-child(even){
background-color:lightgray;
color:blue;
}
</style>
</head>
<body>
<P>Gunjan Jadhav</P>
<div>
<div class="d1">
<h1><center>Saraswati Mandir</center></h1>
<ul id="d1">
<li><a href="about.html">About us</a></li>
<li><a href="contact.html">Contact us</a></li>
<li><a href="feed.html">Feedback</a></li>
<li><a href="scholarship.html">Scholarship</a></li>
</ul>
</div>
<div>
<div class="d2">
<ul>
<li><a href="about.html">About us</a></li>
<li><a href="contact.html">Contact us</a></li>

<li><a href="feed.html">Feedback</a></li>
<li><a href="scholarship.html">Scholarship</a></li>
</ul>
</div>
<div class="d3">
<p>Content of page</p>
<center>
<table>
<tr>
<td>Name
<td>Roll No
<td>Address
</tr>
<tr>Harsh
<td>10
<td>Prabhadevi
</tr>
<tr>
<td>Akansha
<td>5
<td>Dadar
</tr>
<tr>
<td>Raj
<td>20

<td>Bandra
</tr>
<td>Amey
<td>3
<td>Mahim
</tr>
</table>
</center>
</div>
</body>
</html>

Output:

PRACTICAL NO: 5 [JAVASCRIPT]


i. Write a JavaScript code to find sum of first n

numbers. Accept the value for n in prompt dialog


box.

CODE:
<html>
<head>
<title>
Gunjan Jadhav RollNo.37
</title>
<body>
<p>Gunjan Jadhav</p>
<script language=Javascript>
var i=0,n;
var sum=0;
n=window.prompt("Enter some number: ");
for(i=0;i<=n;i++)
{
sum=sum+i;
}
document.writeln("the sum of enter number is="+sum);

</script>
</body>
</html>

Output:

ii. Find factorial of a given number.

CODE:
<html>
<head>
<title>Gunjan Jadhav rollno.37
</title>
</head>
<body>
<p>Gunjan Jadhav</p>
<script language=javaScript>
var n,f=1;
n=window.prompt("Enter a number:");
if(n<0)
{
window.alert(+n+" is a negative number has no factorial");
}
else if(n==0)
{
window.alert("1 is the factorial");
}
else

{
for(i=1;i<=n;i++)
{
f=f*i;
}
window.alert(+f+" is the factorial");
}
</script>
</body>
</html>

Output:

iii. Write a JavaScript program to evaluate any given


expression entered in prompt dialog box.

CODE:
<html>
<head>
<title>Gunjan Jadhav Rollno.37
</title>
<body>
<p>Gunjan Jadhav</p>

<script language=javaScript>
var op,a;
op=window.prompt("Enter the expression");
a=window.eval(op);
document.writeln("Answer="+a);
</script>
</head>
</body>
</html>

Output:

iv. Write a javascript program to find all prime


numbers from 1 100.

CODE:
<html>
<head>
<title>Gunjan Jadhav Rollno.37
</title>
</head>
<body>
<p>Gunjan Jadhav</p>
<script language=javascript>
var i,j,c;
function prime()
{
for(j=3;j<=100;j++)
{
c=0;
for(i=2;i<=(Math.sqrt(j));i++)
{
if(j%i==0)
{
c=c+1;
}
}
if(c==0)
{
document.writeln(j);

}
}
}
</script>
<body onload="prime();">
</body>
</html>

Output:

v. Write a javascript program to find whether the number entered


in the prompt dialog box is a prime or not.

CODE:
<html>

<head>
<title>
Gunjan Jadhav Rollno.37
</title>
</head>
<body onload="prime();">
<p>Gunjan Jadhav</p>
<script language=javascript>
function prime()
{
n=window.prompt("Enter a number:");
c=0;
for(i=2;i<=(Math.sqrt(n));i++)
{
if(n%i==0)
{
c=c+1;
}
}
if(c==0)
{
document.writeln(+n+" is prime");
}
else
{
document.writeln(+n+" is not prime");

}
}
</script>
</body>
</html>

Output:

PRACTICAL NO: 6

[JAVASCRIPT]

i.Write JavaScript code to input a number from the


user&find the sum of squares of odd digits from 1 to the
given number

CODE:
<html>
<head>
<title>Gunjan Jadhav Rollno.37</title>
<body>
<p>Gunjan Jadhav</p>
<script>
var i,n;
var sum=0;
n=window.prompt("Enter the number: ");
for(i=1;i<=n;i++)
{
if(i%2!=0)
{
sum=sum+(i*i);
}
}
document.writeln("The sum of square of odd digits from 1 to "+n+"is
"+sum);
</script>
</head>
</body>
</html>

Output:

ii. Write JavaScript code which will change the background


color of body of HTML page on click of respective color
buttons- Red, Green, Blue present on HTML form.

CODE:
<html>
<title>Gunjan Jadhav Rollno.37</title>
<body>
<p>Gunjan Jadhav</p>
<script>
var n;
n=window.prompt("Enter a number:");
if(n%2==0)
{
document.writeln(+n+" is even");
}
else{
document.writeln(+n+" is odd");
}
</script>
</body>
</html>

Output:

iii. Write JavaScript program to accept lower and upper


range in number. Display sum of all even numbers
between the ranges.

CODE:
<html>
<head>
<title>Gunjan Jadhav Rollno.37
</title>
</head>
<body>
<p>Gunjan Jadhav</p>
<script language="JavaScript">
var i,a,b;
var sum=0;
a=window.prompt("Enter the lower range:");
b=window.prompt("Enter the upper range:");
for(i=a;i<=b;i++)
{
if(i%2==0)
{
sum=sum+i;
}
}

document.writeln("The sum of all even numbers between "+a+"


and "+b+" is "+sum);
</script>
</body>
</html>

Output:

iv. Write JavaScript code which will change the background


color of body of HTML page on click of respective color
buttons- Red, Green, Blue present on HTML form.

CODE:
<html>
<head>
<title>Gunjan Jadhav Rollno.37</title>
<script language="javascript">
var color;
function chBackcolor(color)
{
document.body.style.background=color;
}
</script>
</head>
<body>
<p>Gunjan Jadhav</p>
RED<input type="button" onclick="chBackcolor('red');">
BLUE<input type="button" onclick="chBackcolor('blue');">
GREEN<input type="button" onclick="chBackcolor('green');">
</body>
</html>

Output:

v. Write JavaScript program which will accept 3 digit


number from the user & display multiplication table.

CODE:
<html>
<head>
<title>Gunjan Jadhav Rollno.37</title>
</head>
<body>
<p>Gunjan Jadhav</p>
<script language="javascript">
var n,i,mul;
n=window.prompt("Enter a 3 digit number:");
for(i=1;i<=10;i++)
{
mul=n*i;
document.writeln(+n+"*"+i+"="+mul+"<br><br>");
}
</script>
</body>
</html>

Output:

PRACTICAL NO: 7 [Extensible markup language


(XML)]
Q1.Create a XML page with following structure apply CSS.

CODE:
Css:
<!DOCTYPE LETTER SYSTEM>
<LETTER>
<DATE ALIGN="RIGHT">
June 07, 2016</DATE>
12,Mahindra Heights<BR/>
A.B.P Marg<BR/>
Mumbai Central<BR/>
Mumbai 400 034<BR/>
</INSIDEADDRESS>
<SALUTATION>
Dear Customer Relations Representative:
</SALUTATION>
<BODY>
<P ALIGN="JUSTIFY">
Please confirm your order.
</P>
<P ALIGN="JUSTIFY">
</P>
You may send me a mail confirming Yes or No.
<P>
Thank you for your assistance.
</P>
</BODY>
<CLOSING>
Very truly yours,
</CLOSING>
<SIGNATURE>
Mary Consumer

</SIGNATURE>
</LETTER>

XML:
<?xml version="1.0"?>
<?xml-stylesheet href="tetter1.css"
type="text/css"?>
<!DOCTYPE LETTER [
<!ELEMENT LETTER
(DATE,INSIDEADDRESS,SALUTATION,BODY,CLOSING,SIGNATURE?)>
<!ELEMENT DATE (#PCDATA)>
<!ATTLIST DATE ALIGN (left|right) "left">
<!ELEMENT INSIDEADDRESS (#PCDATA|BR)*>
<!ELEMENT BR EMPTY>
<!ELEMENT SALUTATION (#PCDATA)>
<!ELEMENT BODY (P+)>
<!ELEMENT P (#PCDATA)>
<!ATTLIST P ALIGN (left|justify|right) "left">
<!ELEMENT CLOSING (#PCDATA)>
<!ELEMENT SIGNATURE (#PCDATA)> ]>
<LETTER>
<DATE ALIGN="RIGHT">
June 07, 2016
</DATE>
<INSIDEADDRESS>
12,Mahindra Heights<BR/>

A.B.P Marg<BR/>
Mumbai Central<BR/>
Mumbai 400 034<BR/>
</INSIDEADDRESS>
<SALUTATION>
Dear Customer Relations Representative:
</SALUTATION>
<BODY>
<P ALIGN="JUSTIFY">
Please confirm your order.
</P>
<P ALIGN="JUSTIFY">
You may send me a mail confirming Yes or No.
</P><P>
Thank you for your assistance.

</P>
</BODY>
<CLOSING>
Very truly yours,
</CLOSING>
<SIGNATURE>BNNN
</SIGNATURE>
</LETTER>

Output:

Q2. Create a XML page with following structure apply


CSS.
CODE:
Css:
vehicle {
color:red;display:block
}
mileage {
color:green
}
color {
color:orange
}
price{
color:maroon
}

XML:
<?xml version="1.0"?>
<?xml-stylesheet href="vehicle.css" type="text/css"?>
<!DOCTYPE vehicles[
<!ELEMENT vehicles (vehicle+)>
<!ELEMENT vehicle (mileage,color,model)>
<!ELEMENT mileage (#PCDATA)>
<!ELEMENT color (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ATTLIST vehicle year (1916|1915|1918|1926) "">
<!ATTLIST vehicle make (handrover) "">
<!ATTLIST vehicle model (discovery|jazzy|deluxe|superdeluxe)
"jazzy">]>
<vehicles>
<vehicle year = "1916" make = "handrover"
model="discovery">
<mileage>Gunjan Jadhav Rollno.37</mileage>
<mileage>3650</mileage>
<color>Black</color>

<price>$22100</price>
</vehicle>
<vehicle year = "1918" make = "handrover" model = "jazzy">
<mileage>3880</mileage>
<color>Blue</color>
<price>$24100</price>
</vehicle>
<vehicle year = "1915" make = "handrover" model = "deluxe">
<mileage>3200</mileage>
<color>Golden</color>
<price>$20300</price>
</vehicle>
<vehicle year = "1926" make = "handrover" model = "super
deluxe">
<mileage>3850</mileage>
<color>Silver</color>
<price>$25500</price>
</vehicle>
</vehicles>

OUTPUT:

Practical 8: External Document Type


Definitions
Q.1] Create a XML page with following structure.

CODE:
Css:
personalDetail {color:red}
name {color:green}
firstName {color:green}
middleName{color:green}
lastName{color:green}
address {color:green}
city {color:green}
country{color:green}

XML:
<?xml version="1.0"?>
<?xml-stylesheet
href="name.css
" type="text/css"?>
<!DOCTYPE personalDetail SYSTEM
"name.dtd">
<personalDetail>
<name>
<firstName>Gunjan</firstName>
<middleName>Pratim</middleName>
<lastName>Jadhav</lastName>
</name>
<address>
<city>Mumbai</city>
<country>India</country>
</address>
</personalDetail>

OUTPUT:

PRACTICAL 9: VB CALCULATOR
Q. Create a window application which will have 3 text boxes for
number1, number2 & results. Add buttons for the following tasks:
(+, -, *, power, summation, factorial, series1, series2, SOD,
Reverse).

CODE:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
End Sub
Private Sub btnadd_Click(sender As Object, e As EventArgs) Handles
btnadd.Click
Dim n1 As Integer
Dim n2 As Integer
Dim Res As Integer
n1 = CInt(txtNum1.Text)
n2 = CInt(txtNum2.Text)
Res = n1 + n2
txtResult.Text = Res
End Sub
Private Sub btnSub_Click(sender As Object, e As EventArgs) Handles
btnSub.Click
Dim n1 As Integer
Dim n2 As Integer

Dim Res As Integer


n1 = CInt(txtNum1.Text)
n2 = CInt(txtNum2.Text)
Res = n1 - n2
txtResult.Text = Res
End Sub
Private Sub btnMul_Click(sender As Object, e As EventArgs) Handles
btnMul.Click
Dim n1 As Integer
Dim n2 As Integer
Dim Res As Integer
n1 = CInt(txtNum1.Text)
n2 = CInt(txtNum2.Text)
Res = n1 * n2
txtResult.Text = Res
End Sub
Private Sub btnDiv_Click(sender As Object, e As EventArgs) Handles
btnDiv.Click
Dim n1 As Integer
Dim n2 As Integer
Dim Res As Integer
n1 = CInt(txtNum1.Text)
n2 = CInt(txtNum2.Text)
Res = n1 / n2
txtResult.Text = Res
End Sub

Private Sub btnPower_Click(sender As Object, e As EventArgs) Handles


btnPower.Click
Dim n1 As Integer
Dim n2 As Integer
Dim Res As Integer
n1 = CInt(txtNum1.Text)
n2 = CInt(txtNum2.Text)
Res = 1
For i = 1 To n2
Res = Res * n1
Next
txtResult.Text = Res
End Sub
Private Sub btnSum_Click(sender As Object, e As EventArgs) Handles
btnSum.Click
Dim n1 As Integer
Dim Res As Integer
n1 = CInt(txtNum1.Text)
Res = 0
For i = 1 To n1
Res = Res + i
Next
txtResult.Text = Res
End Sub
Private Sub btnFact_Click(sender As Object, e As EventArgs) Handles
btnFact.Click

Dim n1 As Integer
Dim Res As Integer
n1 = CInt(txtNum1.Text)
Res = 1
For i = 1 To n1
Res = Res * i
Next
txtResult.Text = Res
End Sub
Private Sub btnSeries1_Click(sender As Object, e As EventArgs) Handles
btnSeries1.Click
Dim n1 As Integer
Dim n2 As Integer
Dim Res As Double
n1 = CInt(txtNum1.Text)
n2 = 1
For i = 1 To n1
Res = Res + n2 / i
Next
txtResult.Text = Res
End Sub
Private Sub btnSeries2_Click(sender As Object, e As EventArgs) Handles
btnSeries2.Click
Dim n1 As Integer
Dim n2 As Integer
Dim Res, fff As Double

n1 = CInt(txtNum1.Text)
n2 = 1
For i = 1 To n1
fff = 1
For j = 1 To i
fff = fff * j
Next
Res = Res + (n2 / fff)
Next
txtResult.Text = Res
End Sub
Private Sub btnRev_Click(sender As Object, e As EventArgs) Handles
btnRev.Click
Dim n2, i As String
Dim Letters() As Char
n2 = txtNum2.Text
Letters = n2.ToCharArray()
Array.Reverse(Letters)
Dim Res As New String(Letters, 0, Letters.Length)
txtResult.Text = Res
End Sub
Private Sub btnGrade_Click(sender As Object, e As EventArgs) Handles
btnGrade.Click
Dim n1 As Double
n1 = txtNum1.Text
If (n1 >= 70) Then

txtResult.Text = "O"
ElseIf (n1 >= 60) Then
txtResult.Text = "A"
ElseIf (n1 >= 55) Then
txtResult.Text = "B"
ElseIf (n1 >= 45) Then
txtResult.Text = "C"
ElseIf (n1 >= 40) Then
txtResult.Text = "D"
ElseIf (n1 >= 35) Then
txtResult.Text = "E"
ElseIf (n1 < 35) Then
txtResult.Text = "F"
End If
End Sub
Private Sub btnColor_Click(sender As Object, e As EventArgs) Handles
btnColor.Click
Dim Color As Char
Color = CChar(txtNum1.Text)
Select Case Color
Case "V"
txtResult.Text = "Violet"
Case "I"
txtResult.Text = "Indigo"
Case "B"

txtResult.Text = "Blue"
Case "G"
txtResult.Text = "Green"
Case "Y"
txtResult.Text = "Yellow"
Case "O"
txtResult.Text = "Orange"
Case "R"
txtResult.Text = "Red"
Case Else
txtResult.Text = "Invalid Color"
End Select
End Sub

OUTPUT:

PRACTICAL NO: 10
[Simple Login system & Interest Calculation]

Design a login form containing User Name & Password . The password
should contain max 8 Characters. When user name and password matches
, a welcome message should be displayed otherwise error message
should be displayed . Maximum 3 attempts should be allowed for wrong
passwords otherwise the application should end . If it is proper log in
then allow to open the interest calculation form & calculate the interest.

Code:
Public Class Form1
Dim count As Integer = 0
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
If txtName.Text = "aniket" And txtPassword.Text = "aniket" Then
MessageBox.Show("welcome")
Form2.Show()
Else
MessageBox.Show("Invalid name or password")
count = count + 1
If count > 2 Then
End
End If
End If
End Sub
End Class

Output:

Public Class Form2

Public Function simple_interest(ByVal a As Integer, ByVal b As Integer,


ByVal c As Integer)
a = txtprincipleAmount.Text
b = txtNoofyears.Text
c = txtRateofInterest.Text
Return (a * b * c / 100)
End Function
Private Sub btncalint_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btncalint.Click
Dim x, y, z, d As Integer
d = simple_interest(x, y, z)
txtfutureamt.Text = d
End Sub
End Class

Output:

Practical 11: Simple Calculator


Create a form that accepts 2 numbers from 2 text fields,
an operation (+,-,*,/) from third text field. When you click
Result button, the result of the expression should be
displayed in 4rth disabled text-field. Include a radio
button to choose whether the result should be integer or
float. [Use Select]

CODE:
Public Class Form1
Dim num1 As Single
Dim num2 As Single
Dim optr As String
Private Sub btnResult_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnResult.Click
optr = Trim(txtOperator.Text)
num1 = Val(txtNumber1.Text)
num2 = Val(txtNumber2.Text)
If rbIntegerResult.Checked() Then
Dim result As Integer
Select Case optr
Case "+"
result = num1 + num2
Case "-"
result = num1 - num2
Case "*"
result = num1 * num2
Case "/"
result = num1 / num2
Case Else
MsgBox("Invalid Entry")
End Select
txtResult.Text = result
Else
Dim result As Single
Select Case optr
Case "+"
result = num1 + num2

Case "-"
result = num1 - num2
Case "*"
result = num1 * num2
Case "/"
result = num1 / num2
Case Else
MsgBox("Invalid Entry")
End Select
txtResult.Text = result
End If
End Sub
End Class

Output:

Practical 12:Createb a reservation form


Create a reservation form for Mumbai-Pune journey, containing 3
text-fields to enter names, 3 text-fields to enter age and a text field
to show final bill. It should also contain a radiobutton showing the
type of journey(AC or NonAC). Charges of AC/NonAC mode of
journey is fixed. But only for children(age <5) and senior
citizens(age>60), the rates are half. 4% service charges are applied
on final amount. As per the passengers entered by user, display the
final bill.

Code:
Public Class Form1
Dim username, comp As String
Dim rate, finalrate, sertax As Single
Dim age, tpassenger, counter As Integer
Private Sub btnAddmorepassengers_click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnAddmorepassengers.Click
username = txtName.Text
age = Val(txtAge.Text)
counter += 1
If (age < 5 & age > 60) Then
rate = rate * 0.5
sertax = rate * 0.04
rate = rate + sertax
Else
sertax = rate * 0.04
rate = rate + sertax
End If
finalrate += rate
txtBill.Text += username + " " + age.ToString + " " + comp + " " +
rate.ToString + vbCrLf
End Sub
Private Sub btnCalculate_calculate(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnCalculate.Click
If (counter < tpassenger) Then
txtName.Text = ""
txtAge.Text = ""

txtName.Focus()
rbAC.Checked = False
rbNONAC.Checked = False
Else
btnCalculate.Enabled = False
End If
If counter = txtTotalNoofpassengers.Text Then
txtBill.Text += "total bill: " + finalrate.ToString
End If
End Sub
Private Sub rbNONAC_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles rbNONAC.CheckedChanged
comp = "Non-AC"
rate = 250
End Sub
Private Sub rbAC_CheckedChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles rbAC.CheckedChanged
comp = "AC"
rate = 1500
End Sub
End Class

Output:

Practical 13
Dealing with LISTBOX Control
Create a form containing a list box with names of Indian cricket players.
From this list, two teams should be formed called Royal Challengers &
Knight Riders. The players of these teams should be shown in combo
boxes which are initially empty. For each of these combo-box, two buttons
Add & Delete should be used that allow to make changes When you
click on Add button of a particular team, the selected players from the main
list box, should be added in the combo box. The same players should be
removed from the main list box. Make sure that the number of players
should not exceed 11. When you click on the delete button, a particular
player from the combo-box should be deleted and added to the main list box.

CODE:
Public Class Form1
Private Sub BtnAddRoyals_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles BtnAddRoyals.Click
If ComboRoyals.Items.Count < 11 Then
ComboRoyals.Items.Add(ListBox1.SelectedItem)
ListBox1.Items.Remove(ListBox1.SelectedItem)
Else
MessageBox.Show("Team is Full")
End If
End Sub
Private Sub BtnDelRoyal_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles BtnDelRoyal.Click
ListBox1.Items.Add(ComboRoyals.SelectedItem)
ComboRoyals.Items.Remove(ComboRoyals.SelectedItem)
ComboRoyals.Text = "Royal Challengers"
ListBox1.Sorted = True
End Sub
Private Sub BtnAddRiders_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles BtnAddRiders.Click

If ComboRiders.Items.Count < 11 Then


ComboRiders.Items.Add(ListBox1.SelectedItem)
ListBox1.Items.Remove(ListBox1.SelectedItem)
Else
MessageBox.Show("Team is Full")
End If
End Sub
Private Sub BtnDelRiders_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles BtnDelRiders.Click
ListBox1.Items.Add(ComboRiders.SelectedItem)
ComboRiders.Items.Remove(ComboRiders.SelectedItem)
ComboRiders.Text = "Knight Riders"
ListBox1.Sorted = True
End Sub
End Class

Output:

Practical 14

Validations
Write a program to enter information about customer with name,
age and email in 3 text fields. Name text field should not accept
any digit, age text field should not accept characters and perform
validations on email on lost focus of text field.

CODE:
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub TxtAge_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TxtAge.TextChanged
Dim b1 As Boolean
Dim s As String
Dim i As Integer
s = TxtAge.Text
Dim a(s.Length) As Char
For i = 0 To s.Length - 1
a(i) = (s.Chars(i))
Dim j As Integer = AscW(a(i))
If (j >= 48 And j <= 57) Then
b1 = True
Else
b1 = False
MessageBox.Show("Age is not Valid", "Error",
MessageBoxButtons.OK)
End If
Next
If b1 = True Then
MessageBox.Show("Age is Valid", "Correct Information",
MessageBoxButtons.OK)
End If
End Sub
Private Sub TxtName_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles TxtName.TextChanged
Dim b1 As Boolean
Dim s As String
Dim i As Integer

s = TxtName.Text
Dim a(s.Length) As Char
For i = 0 To s.Length - 1
a(i) = (s.Chars(i))
Dim j As Integer = AscW(a(i))
If (j >= 97 And j <= 122) Or (j >= 65 And j <= 90) Then
b1 = True
Else
b1 = False
MessageBox.Show("Name is not Valid", "Error",
MessageBoxButtons.OK)
End If
Next
If b1 = True Then
MessageBox.Show("Name is Valid", "Correct Information",
MessageBoxButtons.OK)
End If
End Sub
Private Sub TxtEmail_TextChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles TxtEmail.TextChanged
Dim result As Boolean = EmailAddressCheck(TxtEmail.Text)
If result Then
MessageBox.Show("Email is Valid", "Error", MessageBoxButtons.OK)
Else
MessageBox.Show("Email is not Valid", "Error",
MessageBoxButtons.OK)
End If
End Sub
Function EmailAddressCheck(ByVal emailAddress As String) As Boolean
Dim pattern As String = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9]
[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
Dim emailAddressMatch As Match = Regex.Match(emailAddress,
pattern)
If emailAddressMatch.Success Then
EmailAddressCheck = True
Else
EmailAddressCheck = False
End If
End Function
End Class

Output:

Practical 15
Investment Calculator
Write a program to accept information of customer for an
investment policy such as Name, Date of Birth and Address. The
amount to be invested should be selected from a combo box. A
customer can invest from min. age of 21 to 60. According to Date
of birth, determine current age of customer, total number of years
remaining and accordingly find & display the premium that
customer will have to pay.

CODE:
Public Class Form1
Dim bdate As Date
Dim currentdate As Date
Dim age As Integer
Dim pre_amt As Double
Dim policy_amt As Double
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
bdate = CDate(TextBox2.Text)
currentdate = Today
age = DateDiff(DateInterval.Year, bdate, currentdate)
TextBox4.Text = age
TextBox3.Text = 60 - age
If (age >= 21 And age <= 60) Then
pre_amt = policy_amt / TextBox3.Text
TextBox6.Text = pre_amt
Else
MessageBox.Show("you are not valid policy holder ")
End If
End Sub
Private Sub practical7_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ComboBox1.Items.Add("1 Lakh")
ComboBox1.Items.Add("1.5 Lakh")

ComboBox1.Items.Add("2 LAKH")
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ComboBox1.SelectedIndexChanged
Dim amount As Double
Select Case ComboBox1.SelectedIndex
Case 0
amount = 100000
Case 1
amount = 150000
Case 2
amount = 200000
End Select
policy_amt = amount
End Sub
End Class

Output:

Practical 16
Colour & Font Dialog Box

Q A]. Create a form containing 2 buttons to open colour dialog


and font dialog box. The form should contain a label. The labels
font and colour should be set as per the options selected in the
font and colour dialog box.

CODE:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then

label1.ForeColor = ColorDialog1.Color
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
If FontDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then

label1.Font = FontDialog1.Font
End If
End Sub
End Class

Output:

Q B]. Create a form containing a text area and two buttons Read
& Write. When you click on Read button, File-open dialog box is
opened in which when you select a text file its contains should be
displayed in text area. When you click on Write Button, Save-File
dialog box is opened in which you can select a text file in which
the contents of text area will be written.

CODE:
Imports System.IO
Public Class Form1
Dim filereader As StreamReader
Dim filewriter As StreamWriter
Dim filename As String

Private Sub Btnread_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Btnread.Click
Dim ans As DialogResult
OpenFileDialog1.FileName = ""
OpenFileDialog1.Filter = "All Files|*.*|Text Files|*.txt"
OpenFileDialog1.AddExtension = True
If (OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK)
Then
If Not (RichTextBox1.Text) = "" Then
ans = MessageBox.Show("Do you wish to save this content",
"Message", MessageBoxButtons.YesNoCancel)
If ans = Windows.Forms.DialogResult.Yes Then
Btnsave_Click(sender, e)

ElseIf ans = Windows.Forms.DialogResult.No Then


RichTextBox1.Text = ""
End If
Else
filename = OpenFileDialog1.FileName
filereader = New StreamReader(filename)
RichTextBox1.Text = filereader.ReadToEnd
End If
End If

End Sub

Private Sub Btnclr_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Btnclr.Click
RichTextBox1.Text = ""
End Sub

Private Sub Btnsave_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Btnsave.Click
SaveFileDialog1.FileName = ""
SaveFileDialog1.Filter = "All Files|*.*|Text Files|*.txt"
SaveFileDialog1.AddExtension = True
If (SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK)
Then
filename = SaveFileDialog1.FileName
filewriter = New StreamWriter(filename)

filewriter.WriteLine(RichTextBox1.Text)
filewriter.Close()
End If

End Sub

End Class

Output:

Practical 17
Application with MDI form
Create a MDI form containing 2 menus Current Releases &
Forthcoming. Current Releases should contain 2 sub-menus
Hindi & English. Each menu opens a form containing some list of
specific films in combo-box. When you select the name of the
film, its information such as star-cast, movie type
(comedy/suspense/action/drama etc), production etc should be
displayed in labels. It should also show its ratings in the status
bar. When you click on Forthcoming films, it should open a form
containing some names of films in list-box. The list of films should
be specified in array-list.

CODE:
Imports System.Windows.Forms
Public Class MDIParent1
Private Sub ShowNewForm(ByVal sender As Object, ByVal e As EventArgs)
' Create a new instance of the child form.
Dim ChildForm As New System.Windows.Forms.Form
' Make it a child of this MDI form before showing it.
ChildForm.MdiParent = Me
m_ChildFormNumber += 1
ChildForm.Text = "Window " & m_ChildFormNumber
ChildForm.Show()
End Sub
Private Sub OpenFile(ByVal sender As Object, ByVal e As EventArgs)
Dim OpenFileDialog As New OpenFileDialog
OpenFileDialog.InitialDirectory =
My.Computer.FileSystem.SpecialDirectories.MyDocuments
OpenFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"

If (OpenFileDialog.ShowDialog(Me) =
System.Windows.Forms.DialogResult.OK) Then
Dim FileName As String = OpenFileDialog.FileName
' TODO: Add code here to open the file.
End If
End Sub
Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As Object, ByVal
e As EventArgs)
Dim SaveFileDialog As New SaveFileDialog
SaveFileDialog.InitialDirectory =
My.Computer.FileSystem.SpecialDirectories.MyDocuments
SaveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
If (SaveFileDialog.ShowDialog(Me) =
System.Windows.Forms.DialogResult.OK) Then
Dim FileName As String = SaveFileDialog.FileName
' TODO: Add code here to save the current contents of the form to a
file.
End If
End Sub
Private Sub ExitToolsStripMenuItem_Click(ByVal sender As Object, ByVal e
As EventArgs)
Me.Close()
End Sub
Private Sub CutToolStripMenuItem_Click(ByVal sender As Object, ByVal e
As EventArgs)
' Use My.Computer.Clipboard to insert the selected text or images into
the clipboard
End Sub
Private Sub CopyToolStripMenuItem_Click(ByVal sender As Object, ByVal e
As EventArgs)
' Use My.Computer.Clipboard to insert the selected text or images into
the clipboard
End Sub
Private Sub PasteToolStripMenuItem_Click(ByVal sender As Object, ByVal e
As EventArgs)
'Use My.Computer.Clipboard.GetText() or
My.Computer.Clipboard.GetData to retrieve information from the clipboard.
End Sub

Private Sub ToolBarToolStripMenuItem_Click(ByVal sender As Object, ByVal


e As EventArgs)
Me.StatusBarToolStripMenuItem.Visible =
Me.ToolBarToolStripMenuItem.Checked
End Sub

Private Sub CascadeToolStripMenuItem_Click(ByVal sender As Object,


ByVal e As EventArgs)
Me.LayoutMdi(MdiLayout.Cascade)
End Sub
Private Sub TileVerticalToolStripMenuItem_Click(ByVal sender As Object,
ByVal e As EventArgs)
Me.LayoutMdi(MdiLayout.TileVertical)
End Sub
Private Sub TileHorizontalToolStripMenuItem_Click(ByVal sender As Object,
ByVal e As EventArgs)
Me.LayoutMdi(MdiLayout.TileHorizontal)
End Sub
Private Sub ArrangeIconsToolStripMenuItem_Click(ByVal sender As Object,
ByVal e As EventArgs)
Me.LayoutMdi(MdiLayout.ArrangeIcons)
End Sub
Private Sub CloseAllToolStripMenuItem_Click(ByVal sender As Object, ByVal
e As EventArgs)
' Close all child forms of the parent.
For Each ChildForm As Form In Me.MdiChildren
ChildForm.Close()
Next
End Sub
Private m_ChildFormNumber As Integer
Private Sub EmpFormToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ToolBarToolStripMenuItem.Click
FrmEmp.MdiParent = Me
FrmEmp.Show()
FrmDept.Close()
End Sub

Private Sub DeptFormToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
DeptFormToolStripMenuItem.Click
FrmDept.MdiParent = Me
FrmDept.Show()
FrmEmp.Close()
End Sub
End Class

Output:

S-ar putea să vă placă și