VPT Lab-Manual For Students
VPT Lab-Manual For Students
VPT Lab-Manual For Students
LAB REPORT
(VISUAL PROGRAMMING LAB)
SEMESTER _________________________________
SESSION _________________________________
1
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
This Guide is designed for helping the students to perform better in various practical
Courses. It describes the structure of a good laboratory report, outlines the different
sections of the report and explains the need for each of them. It also introduces some
standard conventions and rules for writing reports of professional quality. The quality
of your written report will strongly affect your grade for the course.
2
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
DO’S
Remember this is a practice lab & Keep silence.
Sit down in proper manner.
Lab instructor can help you to access software and printer.
If you require more in depth help you can ask concern lecturer
Proper shut down the computer system before leaving the lab.
Exit lab quickly, if short circuit or any emergency occurs.
You must entry when you enter and leave the lab.
DON’T
Write any thing on the furniture.
Delete or change other student’s file.
Uninstall the any Software.
Inter change any Hardware.
Create, Change or remove any password.
Exhibit disruptive behavior.
Chatting and other banned sites.
Play computer games.
Eat and drink in Lab
3
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
EVALUATION REPORT
4
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
CODING/PROCEDURE:
The framework's Base Class Library provides a large range of features including user
interface, data access, database connectivity, cryptography, web application
development, numeric algorithms, and network communications. The class library is
used by programmers, who combine it with their own code to produce applications.
Programs written for the .NET Framework execute in a software environment that
manages the program's runtime requirements. Also part of the .NET Framework, this
runtime environment is known as the Common Language Runtime (CLR). The CLR
provides the appearance of an application virtual machine so that programmers need
not consider the capabilities of the specific CPU that will execute the program. The
CLR also provides other important services such as security, memory management,
and exception handling. The class library and the CLR together constitute the .NET
Framework.
The .NET Framework is a Microsoft offering and is intended to be used by most new
applications created for the Windows platform. In order to be able to develop and not
just run applications for the Microsoft .NET Framework 4.0, it is required to have
Microsoft's SDK for Windows 7 or .NET Framework 4 (or newer) or Visual Studio
2010 installed on your computer.
5
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
Interoperability
Because computer systems commonly require interaction between new and
older applications, the .NET Framework provides means to access functionality
that is implemented in programs that execute outside the .NET environment.
Access to COM components is provided in the System.Runtime.InteropServices
and System.EnterpriseServices namespaces of the framework; access to other
functionality is provided using the P/Invoke feature.
Common Runtime Engine
The Common Language Runtime (CLR) is the execution engine of the .NET
Framework. All .NET programs execute under the supervision of the CLR,
guaranteeing certain properties and behaviors in the areas of memory
management, security, and exception handling.
Language Independence
The .NET Framework introduces a Common Type System, or CTS. The CTS
specification defines all possible datatypes and programming constructs
supported by the CLR and how they may or may not interact with each other
conforming to the Common Language Infrastructure (CLI) specification.
Because of this feature, the .NET Framework supports the exchange of types
and object instances between libraries and applications written using any
conforming .NET language.
Base Class Library
The Base Class Library (BCL), part of the Framework Class Library (FCL), is a
library of functionality available to all languages using the .NET Framework.
The BCL provides classes which encapsulate a number of common functions,
including file reading and writing, graphic rendering, database interaction,
XML document manipulation and so on.
Simplified Deployment
The .NET Framework includes design features and tools that help manage the
installation of computer software to ensure that it does not interfere with
previously installed software, and that it conforms to security requirements.
Security
The design is meant to address some of the vulnerabilities, such as buffer
overflows, that have been exploited by malicious software. Additionally, .NET
provides a common security model for all applications.
6
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
Portability
Versions
7
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
Viva Questions:
8
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
9
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
Aim Design an application that uses the user defined Dynamic Link
Library in VB.NET
CODING/PROCEDURE:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ClassLibrary1;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
int a, b, c;
Class1 o = new Class1();
public Form1()
{
InitializeComponent();
}
// Addition
private void button1_Click(object sender, EventArgs e)
{
a = Int32.Parse(textBox1.Text);
b = Int32.Parse(textBox2.Text);
c = o.add(a,b);
MessageBox.Show("Addition is "+c.ToString());
}
// Subtraction
private void button2_Click(object sender, EventArgs e)
{
10
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
a = Int32.Parse(textBox3.Text);
b = Int32.Parse(textBox4.Text);
c = o.sub(a,b);
MessageBox.Show("Subtraction is " + c.ToString());
}
// Swaping
}
}
// Class Library
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ClassLibrary1
{
public class Class1
{
public int add(int a, int b)
{
return (a + b);
}
public int sub(int a, int b)
{
return (a - b);
}
public void swap(ref int a, ref int b)
{
11
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
int c;
c = a;
a = b;
b = c;
}
public int fact(int b)
{
int a = 1;
for (int i = b; i > 0; i--)
{
a = a * i;
}
return a;
}
}
}
12
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
Result :-
13
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
Viva Questions:
1. What is Class Library?
2. What is Object Sender, Event Arguments?
14
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
CODING/PROCEDURE:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace GraphicsApp
{
public partial class Form1 : Form
{
Graphics g;
int count;
Random rand = new Random();
int rr, gg, bb;
public Form1()
{
InitializeComponent();
}
private void Form1_MouseClick(object sender, MouseEventArgs e)
{
rr = rand.Next(255);
gg = rand.Next(255);
bb = rand.Next(255);
Pen p = new Pen(Color.FromArgb(rr,gg,bb));
if (count < 20)
{
g.DrawEllipse(p, e.X - 40, e.Y - 40, 100, 100);
count++;
}
else
{
MessageBox.Show("No more Circles");
15
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
}
}
private void Form1_Load(object sender, EventArgs e)
{
g = CreateGraphics();
}
}
}
16
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
Result :-
Viva Questions:
1. What is using System.ComponentModel?
2. What is using System. Collections.Generic?
17
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
CODING/PROCEDURE:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Analog_Clock
{
public partial class Form1 : Form
{
Graphics g;
float x1, y1,x2,y2,x3,y3,inc1,inc2,inc3,sx,sy,th4;
float th1 = -90 + DateTime.Now.Second*6;
float th2 = -90 + DateTime.Now.Minute * 6 + DateTime.Now.Second * 1.0f / 10;
float th3 = -90 + DateTime.Now.Hour * 30 + DateTime.Now.Minute * 1.0f / 2 +
DateTime.Now.Second * 1.0f / 120;
public Form1()
{
InitializeComponent();
}
18
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
19
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
Result :-
Viva Questions:
1. What is Call by value & Call by Reference?
2. What is PaintEventArguments?
20
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
CODING/PROCEDURE:
Steps 6: Right click on the form, and choose properties from the menu.
21
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
Coding:
Event Click()
Event KeyPress(KeyAscii As Integer)
Steps 9: Now lets see how the control is working by now.Save the project (File->Save
Project).
22
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
Steps 10: Compile the project to OCX Control.From the menu, choose File->Make
MyFirstOCX.ocx and press OK.
Steps 11: Start a new project and enter your control to the project .From the menu
choose Project->Components.
Steps 12: Now you see the new control at the ToolBox.
23
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
Result :-
Viva Questions:
1. What is ActiveX control?
2. What is KeyAscii?
24
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
CODING/PROCEDURE:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
25
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
}
sqlConnection1.Close();
}
// Table Data
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication3
{
public partial class Form2 : Form
{
int i;
SqlDataAdapter da;
DataSet ds = new DataSet();
public Form2()
{
InitializeComponent();
}
26
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
label6.Text = ds.Tables[0].Rows[i].ItemArray[0].ToString();
label7.Text = ds.Tables[0].Rows[i].ItemArray[1].ToString();
label8.Text = ds.Tables[0].Rows[i].ItemArray[2].ToString();
label9.Text = ds.Tables[0].Rows[i].ItemArray[3].ToString();
label10.Text = ds.Tables[0].Rows[i].ItemArray[4].ToString();
}
i++;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
sqlConnection1.Close();
}
}
}
27
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
Result :-
Viva Questions:
1. What is Database and SQl Server?
2. What is Dataset?
28
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
Aim Design an application that uses the concept of Dialog Control using
VB.Net
CODING/PROCEDURE:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
29
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
{
timer1.Start();
}
else
{
MessageBox.Show("Please Select Address");
}
}
int i = 0;
private void timer1_Tick(object sender, EventArgs e)
{
if (i < listBox1.Items.Count)
{
pictureBox1.Image = Image.FromFile(listBox1.Items[i].ToString());
i++;
}
else
{
i = 0;
}
}
30
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
Result :-
Viva Questions:
1. What is Dialog Control?
2. What is Namespace ?
31
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
32
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
CODING/PROCEDURE:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// Insertion
private void button1_Click(object sender, EventArgs e)
{
try
{
sqlConnection1.Open();
sqlCommand1.Connection = sqlConnection1;
sqlCommand1.CommandText = "insert into student values('" + textBox1.Text + "','" +
textBox2.Text+ "','" + comboBox1.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')";
sqlCommand1.ExecuteNonQuery();
MessageBox.Show("Data Inserted");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
33
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
sqlConnection1.Close();
}
// Updation
private void button2_Click(object sender, EventArgs e)
{
try
{
sqlConnection1.Open();
sqlCommand1.Connection = sqlConnection1;
sqlCommand1.CommandText = "update student set Address='"+textBox4.Text+"' where
(Roll='"+textBox1.Text+"')";
sqlCommand1.ExecuteNonQuery();
MessageBox.Show("Data Updated");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
sqlConnection1.Close();
}
// Deletion
private void button3_Click(object sender, EventArgs e)
{
try
{
sqlConnection1.Open();
sqlCommand1.Connection = sqlConnection1;
sqlCommand1.CommandText = "delete from student where (Roll='"+textBox1.Text+"')";
sqlCommand1.ExecuteNonQuery();
MessageBox.Show("Data Deleted");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
sqlConnection1.Close();
}
}
}
34
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
Result :-
Viva Questions:
1. What is Sql Server& SqlDataAdapter ?
2. What is Data Grid ?
35
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
CODING/PROCEDURE:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Calculator
{
public partial class Form1 : Form
{
int status = 0,st=0;
double res, num1;
String opstate;
public Form1()
{
InitializeComponent();
}
status = 1;
}
else if (status == 1 && textBox1.Text.Length < 12)
{
textBox1.Text = textBox1.Text + "7";
}
}
36
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
37
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
38
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
status = 1;
}
else if (status == 1 && textBox1.Text.Length < 12)
{
textBox1.Text = textBox1.Text + "1";
}
}
39
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
40
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
41
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
textBox1.Text = res.ToString();
}
break;
}
case "mul":
{
if (st == 1)
{
res = num1 * Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
}
else if (st > 1)
{
res = res * Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
}
break;
}
case "div":
{
if (st == 1)
{
res = num1 / Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
}
else if (st > 0)
{
res = res / Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
}
break;
}
default:
{
break;
}
}
}
opstate = "";
}
42
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
}
else if (st == 1 && status == 1)
{
switch (opstate)
{
case "plus":
{
res = num1 + Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
case "minus":
{
res = num1 - Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
case "mul":
{
res = num1 * Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
case "div":
{
res = num1 / Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
default:
{
break;
}
}
status = 0;
st++;
}
else if (st >= 1 && status == 1)
{
switch (opstate)
{
case "plus":
{
res = res + Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
case "minus":
43
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
{
res = res - Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
case "mul":
{
res = res * Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
case "div":
{
res = res / Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
default:
{
break;
}
}
status = 0;
}
else
{
textBox1.Text = res.ToString();
}
opstate="minus";
}
44
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
}
case "minus":
{
res = num1 - Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
case "mul":
{
res = num1 * Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
case "div":
{
res = num1 / Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
default:
{
break;
}
}
status = 0;
st++;
}
else if (st > 1 && status == 1)
{
switch (opstate)
{
case "plus":
{
res = res + Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
case "minus":
{
res = res - Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
case "mul":
{
res = res * Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
45
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
}
case "div":
{
res = res / Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
default:
{
break;
}
}
status = 0;
}
else
{
textBox1.Text = res.ToString();
}
opstate = "mul";
}
46
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
textBox1.Text = res.ToString();
break;
}
case "div":
{
res = num1 / Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
default:
{
break;
}
}
status = 0;
st++;
}
else if (st > 1 && status == 1)
{
switch (opstate)
{
case "plus":
{
res = res + Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
case "minus":
{
res = res - Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
case "mul":
{
res = res * Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
case "div":
{
res = res / Int32.Parse(textBox1.Text);
textBox1.Text = res.ToString();
break;
}
default:
{
break;
47
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
}
}
status = 0;
}
else
{
textBox1.Text = res.ToString();
}
opstate = "div";
}
48
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
}
}
}
49
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
Result :-
Viva Questions:
1. What is Conditional Statements?
2. What is System.Windows.Forms ?
50
HARYANA INSTITUTE OF TECHNOLOGY VISUAL PROGRAMMING LAB (CSE-312-F)
51