Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 20

UNIVERSITY OF NORTH BENGAL

2020 -2021

IT 52 L : .NET FRAMEWORK LAB

Submitted to –
Rakesh Kumar Mandal

-------------------------------------

Assignment By –
Nisha Choudhary
MCA 5th sem
Roll no. - 19
ASSIGNMENT 1
Steps to download VB .NET

Step 1: For downloading the Visual Studio IDE, go through the link:
https://www.visualstudio.com/downloads

Step 2: As clicked on download link, it starts downloading an .exe file

Step 3: Click on the .exe file and then, it shows a pop-up window.

Step 4: Click on the Run button, and then visual studio installer starts running.

Step 5: Click on the Continue Button

Step 6: After clicking on Continue, Visual Studio will start downloading its initial
files.

Step 7: After the next screen appears click on the install button.

Step 8: Your Visual Studio IDE will start downloading.

Step 9: select .NET desktop development and click on install.

Step 10: Click o launch button, then a screen appears which shows that Visual
Studio has been successfully launched in your machine.

Step 11: After selecting the Theme, click on Start Visual Studio.
ASSIGNMENT 2
Steps to make a simple calculator

Step 1: Open Microsoft Visual Basic .Net

Step 2: Select New Project

Step 3: Select Standard EXE

Step 4: Name the project, set your file location and save it.

Step 5: If needed, click on the view tab  select the Toolbox Property  Project
Explorer  Properties window.

Step 6: Click anywhere on the form.

Step 7: Click on properties window  Caption property  Type name of your


calculator

Step 8: Design the calculator as per your requirement by dragging and dropping
from toolbox to the form.

Step 9: Using the properties window change text, font, color, background etc.

Step 10: Double click on each button of your calculator to open the code window.

Step 11: Write the corresponding project, save it then run and make changes
accordingly.
SOURCE CODE
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Calculator
{
public partial class Form1 : Form
{
Double resultValue = 0;
String OperationPerformed = "";
bool isOperationPerformed = false;
public Form1()
{
InitializeComponent();
}

private void button_click(object sender, EventArgs e)


{
if ((textBox_result.Text == "0") || (isOperationPerformed))
textBox_result.Clear();

isOperationPerformed = false;
Button button = (Button)sender;

if (button.Text==".")
{
if(!textBox_result.Text.Contains("."))
textBox_result.Text = textBox_result.Text + button.Text;
}
else
textBox_result.Text = textBox_result.Text + button.Text;
}

private void operator_click(object sender, EventArgs e)


{
Button button = (Button)sender;

if (resultValue != 0)
{
button11.PerformClick();
OperationPerformed = button.Text;
labelCurrentOperation.Text = resultValue + " " + OperationPerformed;
isOperationPerformed = true;
else
{
OperationPerformed = button.Text;
resultValue = Double.Parse(textBox_result.Text);
labelCurrentOperation.Text = resultValue + " " + OperationPerformed;
isOperationPerformed = true;
}
}

private void button5_click(object sender, EventArgs e)


{
textBox_result.Text = "0";
}

private void button6_Click(object sender, EventArgs e)


{
textBox_result.Text = "0";
resultValue = 0;
}

private void button11_Click(object sender, EventArgs e)


{
switch(OperationPerformed)
{
case "+":
textBox_result.Text = (resultValue +
Double.Parse(textBox_result.Text)).ToString();
break;

case "-":
textBox_result.Text = (resultValue -
Double.Parse(textBox_result.Text)).ToString();
break;

case "*":
textBox_result.Text = (resultValue *
Double.Parse(textBox_result.Text)).ToString();
break;

case "/":
textBox_result.Text = (resultValue /
Double.Parse(textBox_result.Text)).ToString();
break;

default:
break;
}
resultValue = Double.Parse(textBox_result.Text);
labelCurrentOperation.Text = "";
}
}
}
DESIGN CODE

namespace WindowsFormsApplication4

partial class Form1

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.IContainer components = null;

/// <summary>

/// Clean up any resources being used.

/// </summary>

/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>

protected override void Dispose(bool disposing)

if (disposing && (components != null))

components.Dispose();

base.Dispose(disposing);

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

this.button1 = new System.Windows.Forms.Button();

this.button2 = new System.Windows.Forms.Button();

this.button3 = new System.Windows.Forms.Button();

this.button4 = new System.Windows.Forms.Button();

this.button5 = new System.Windows.Forms.Button();

this.button6 = new System.Windows.Forms.Button();

this.button7 = new System.Windows.Forms.Button();

this.button8 = new System.Windows.Forms.Button();

this.button9 = new System.Windows.Forms.Button();

this.button10 = new System.Windows.Forms.Button();

this.button11 = new System.Windows.Forms.Button();

this.button12 = new System.Windows.Forms.Button();

this.button13 = new System.Windows.Forms.Button();

this.button14 = new System.Windows.Forms.Button();

this.button15 = new System.Windows.Forms.Button();

this.button17 = new System.Windows.Forms.Button();

this.button18 = new System.Windows.Forms.Button();

this.button20 = new System.Windows.Forms.Button();

this.textBox_result = new System.Windows.Forms.TextBox();

this.labelCurrentOperation = new System.Windows.Forms.Label();

this.SuspendLayout();

//
// button1

//

this.button1.BackColor = System.Drawing.SystemColors.ButtonFace;

this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold,


System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.button1.Location = new System.Drawing.Point(42, 89);

this.button1.Name = "button1";

this.button1.Size = new System.Drawing.Size(47, 40);

this.button1.TabIndex = 0;

this.button1.Text = "7";

this.button1.UseVisualStyleBackColor = false;

this.button1.Click += new System.EventHandler(this.button_click);

//

// button2

//

this.button2.BackColor = System.Drawing.SystemColors.ButtonFace;

this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold,


System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.button2.Location = new System.Drawing.Point(96, 89);

this.button2.Name = "button2";

this.button2.Size = new System.Drawing.Size(47, 40);

this.button2.TabIndex = 1;

this.button2.Text = "8";

this.button2.UseVisualStyleBackColor = false;

this.button2.Click += new System.EventHandler(this.button_click);

//

// button3

//
this.button3.BackColor = System.Drawing.SystemColors.ButtonFace;

this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold,


System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.button3.Location = new System.Drawing.Point(149, 89);

this.button3.Name = "button3";

this.button3.Size = new System.Drawing.Size(47, 40);

this.button3.TabIndex = 2;

this.button3.Text = "9";

this.button3.UseVisualStyleBackColor = false;

this.button3.Click += new System.EventHandler(this.button_click);

//

// button4

//

this.button4.BackColor = System.Drawing.SystemColors.ButtonFace;

this.button4.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold,


System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.button4.Location = new System.Drawing.Point(203, 89);

this.button4.Name = "button4";

this.button4.Size = new System.Drawing.Size(47, 40);

this.button4.TabIndex = 3;

this.button4.Text = "/";

this.button4.UseVisualStyleBackColor = false;

this.button4.Click += new System.EventHandler(this.operator_click);

//

// button5

//

this.button5.BackColor = System.Drawing.SystemColors.ButtonFace;
this.button5.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.button5.Location = new System.Drawing.Point(257, 90);

this.button5.Name = "button5";

this.button5.Size = new System.Drawing.Size(58, 40);

this.button5.TabIndex = 4;

this.button5.Text = "CE";

this.button5.UseVisualStyleBackColor = false;

this.button5.Click += new System.EventHandler(this.button5_click);

//

// button6

//

this.button6.BackColor = System.Drawing.SystemColors.ButtonFace;

this.button6.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold,


System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.button6.Location = new System.Drawing.Point(257, 135);

this.button6.Name = "button6";

this.button6.Size = new System.Drawing.Size(58, 40);

this.button6.TabIndex = 9;

this.button6.Text = "C";

this.button6.UseVisualStyleBackColor = false;

this.button6.Click += new System.EventHandler(this.button6_Click);

//

// button7

//

this.button7.BackColor = System.Drawing.SystemColors.ButtonFace;

this.button7.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold,


System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button7.Location = new System.Drawing.Point(203, 135);

this.button7.Name = "button7";

this.button7.Size = new System.Drawing.Size(47, 40);

this.button7.TabIndex = 8;

this.button7.Text = "*";

this.button7.UseVisualStyleBackColor = false;

this.button7.Click += new System.EventHandler(this.operator_click);

//

// button8

//

this.button8.BackColor = System.Drawing.SystemColors.ButtonFace;

this.button8.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold,


System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.button8.Location = new System.Drawing.Point(149, 135);

this.button8.Name = "button8";

this.button8.Size = new System.Drawing.Size(47, 40);

this.button8.TabIndex = 7;

this.button8.Text = "6";

this.button8.UseVisualStyleBackColor = false;

this.button8.Click += new System.EventHandler(this.button_click);

//

// button9

//

this.button9.BackColor = System.Drawing.SystemColors.ButtonFace;

this.button9.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold,


System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.button9.Location = new System.Drawing.Point(96, 135);

this.button9.Name = "button9";
this.button9.Size = new System.Drawing.Size(47, 40);

this.button9.TabIndex = 6;

this.button9.Text = "5";

this.button9.UseVisualStyleBackColor = false;

this.button9.Click += new System.EventHandler(this.button_click);

//

// button10

//

this.button10.BackColor = System.Drawing.SystemColors.ButtonFace;

this.button10.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold,


System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.button10.Location = new System.Drawing.Point(42, 135);

this.button10.Name = "button10";

this.button10.Size = new System.Drawing.Size(47, 40);

this.button10.TabIndex = 5;

this.button10.Text = "4";

this.button10.UseVisualStyleBackColor = false;

this.button10.Click += new System.EventHandler(this.button_click);

//

// button11

//

this.button11.BackColor = System.Drawing.SystemColors.ButtonFace;

this.button11.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold,


System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.button11.Location = new System.Drawing.Point(257, 181);

this.button11.Name = "button11";

this.button11.Size = new System.Drawing.Size(58, 86);

this.button11.TabIndex = 14;
this.button11.Text = "=";

this.button11.UseVisualStyleBackColor = false;

this.button11.Click += new System.EventHandler(this.button11_Click);

//

// button12

//

this.button12.BackColor = System.Drawing.SystemColors.ButtonFace;

this.button12.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold,


System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.button12.Location = new System.Drawing.Point(203, 181);

this.button12.Name = "button12";

this.button12.Size = new System.Drawing.Size(47, 40);

this.button12.TabIndex = 13;

this.button12.Text = "-";

this.button12.UseVisualStyleBackColor = false;

this.button12.Click += new System.EventHandler(this.operator_click);

//

// button13

//

this.button13.BackColor = System.Drawing.SystemColors.ButtonFace;

this.button13.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold,


System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.button13.Location = new System.Drawing.Point(149, 181);

this.button13.Name = "button13";

this.button13.Size = new System.Drawing.Size(47, 40);

this.button13.TabIndex = 12;

this.button13.Text = "3";

this.button13.UseVisualStyleBackColor = false;
this.button13.Click += new System.EventHandler(this.button_click);

//

// button14

//

this.button14.BackColor = System.Drawing.SystemColors.ButtonFace;

this.button14.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold,


System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.button14.Location = new System.Drawing.Point(96, 181);

this.button14.Name = "button14";

this.button14.Size = new System.Drawing.Size(47, 40);

this.button14.TabIndex = 11;

this.button14.Text = "2";

this.button14.UseVisualStyleBackColor = false;

this.button14.Click += new System.EventHandler(this.button_click);

//

// button15

//

this.button15.BackColor = System.Drawing.SystemColors.ButtonFace;

this.button15.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold,


System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.button15.Location = new System.Drawing.Point(42, 181);

this.button15.Name = "button15";

this.button15.Size = new System.Drawing.Size(47, 40);

this.button15.TabIndex = 10;

this.button15.Text = "1";

this.button15.UseVisualStyleBackColor = false;

this.button15.Click += new System.EventHandler(this.button_click);

//
// button17

//

this.button17.BackColor = System.Drawing.SystemColors.ButtonFace;

this.button17.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold,


System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.button17.Location = new System.Drawing.Point(203, 227);

this.button17.Name = "button17";

this.button17.Size = new System.Drawing.Size(47, 40);

this.button17.TabIndex = 18;

this.button17.Text = "+";

this.button17.UseVisualStyleBackColor = false;

this.button17.Click += new System.EventHandler(this.operator_click);

//

// button18

//

this.button18.BackColor = System.Drawing.SystemColors.ButtonFace;

this.button18.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold,


System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.button18.Location = new System.Drawing.Point(149, 227);

this.button18.Name = "button18";

this.button18.Size = new System.Drawing.Size(47, 40);

this.button18.TabIndex = 17;

this.button18.Text = ".";

this.button18.UseVisualStyleBackColor = false;

this.button18.Click += new System.EventHandler(this.button_click);

//

// button20

//
this.button20.BackColor = System.Drawing.SystemColors.ButtonFace;

this.button20.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold,


System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.button20.Location = new System.Drawing.Point(42, 227);

this.button20.Name = "button20";

this.button20.Size = new System.Drawing.Size(100, 40);

this.button20.TabIndex = 15;

this.button20.Text = "0";

this.button20.UseVisualStyleBackColor = false;

this.button20.Click += new System.EventHandler(this.button_click);

//

// textBox_result

//

this.textBox_result.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F,


System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.textBox_result.Location = new System.Drawing.Point(42, 48);

this.textBox_result.Name = "textBox_result";

this.textBox_result.Size = new System.Drawing.Size(272, 26);

this.textBox_result.TabIndex = 19;

this.textBox_result.Text = "0";

this.textBox_result.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;

//

// labelCurrentOperation

//

this.labelCurrentOperation.AutoSize = true;

this.labelCurrentOperation.BackColor = System.Drawing.SystemColors.ButtonHighlight;

this.labelCurrentOperation.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F,


System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.labelCurrentOperation.Location = new System.Drawing.Point(38, 32);

this.labelCurrentOperation.Name = "labelCurrentOperation";

this.labelCurrentOperation.Size = new System.Drawing.Size(35, 13);

this.labelCurrentOperation.TabIndex = 20;

this.labelCurrentOperation.Text = "label1";

//

// Form1

//

this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 13F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize = new System.Drawing.Size(380, 332);

this.Controls.Add(this.labelCurrentOperation);

this.Controls.Add(this.textBox_result);

this.Controls.Add(this.button17);

this.Controls.Add(this.button18);

this.Controls.Add(this.button20);

this.Controls.Add(this.button11);

this.Controls.Add(this.button12);

this.Controls.Add(this.button13);

this.Controls.Add(this.button14);

this.Controls.Add(this.button15);

this.Controls.Add(this.button6);

this.Controls.Add(this.button7);

this.Controls.Add(this.button8);

this.Controls.Add(this.button9);

this.Controls.Add(this.button10);

this.Controls.Add(this.button5);
this.Controls.Add(this.button4);

this.Controls.Add(this.button3);

this.Controls.Add(this.button2);

this.Controls.Add(this.button1);

this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold,


System.Drawing.GraphicsUnit.Point, ((byte)(0)));

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;

this.MinimizeBox = false;

this.Name = "Form1";

this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

this.Text = "Calculator";

this.Load += new System.EventHandler(this.Form1_Load);

this.ResumeLayout(false);

this.PerformLayout();

#endregion

private System.Windows.Forms.Button button1;

private System.Windows.Forms.Button button2;

private System.Windows.Forms.Button button3;

private System.Windows.Forms.Button button4;

private System.Windows.Forms.Button button5;

private System.Windows.Forms.Button button6_click;

private System.Windows.Forms.Button button7;

private System.Windows.Forms.Button button8;


private System.Windows.Forms.Button button9;

private System.Windows.Forms.Button button10;

private System.Windows.Forms.Button button11;

private System.Windows.Forms.Button button12;

private System.Windows.Forms.Button button13;

private System.Windows.Forms.Button button14;

private System.Windows.Forms.Button button15;

private System.Windows.Forms.Button button17;

private System.Windows.Forms.Button button18;

private System.Windows.Forms.Button button20;

private System.Windows.Forms.TextBox textBox_result;

private System.Windows.Forms.Label labelCurrentOperation;

private System.Windows.Forms.Button button6;

}
Design Layout

Output Example

Operation 1 Operation 2 Operation 3

You might also like