0% found this document useful (0 votes)
25 views7 pages

Aaasss

The program shows how to create a scientific calculator application in Windows forms. It includes buttons for numbers, operators, and functions to perform calculations when the equals button is clicked.

Uploaded by

ehisoeine123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views7 pages

Aaasss

The program shows how to create a scientific calculator application in Windows forms. It includes buttons for numbers, operators, and functions to perform calculations when the equals button is clicked.

Uploaded by

ehisoeine123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

6.Write a program with controls to prepare a scientific calculator in windows applications.

Ans:

Public Class Form1

Dim num1 As Decimal

Dim num2 As Decimal

Dim op As String

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

TextBox1.Text += "1"

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

TextBox1.Text += "2"

End Sub

Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click

TextBox1.Text += "3"

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

TextBox1.Text += "4"

End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click

TextBox1.Text += "5"

End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click

TextBox1.Text += "6"
End Sub

Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click

TextBox1.Text += "7"

End Sub

Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click

TextBox1.Text += "8"

End Sub

Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click

TextBox1.Text += "9"

End Sub

Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click

TextBox1.Text += "0"

End Sub

Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click

TextBox1.Text += "."

End Sub

Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click

num1 = TextBox1.Text

TextBox1.Text = ""

op = "+"

TextBox2.Text = "+"

End Sub

Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click

num1 = TextBox1.Text
TextBox1.Text = ""

op = "-"

TextBox2.Text = "-"

End Sub

Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click

num1 = TextBox1.Text

TextBox1.Text = ""

op = "*"

TextBox2.Text = "*"

End Sub

Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Button17.Click

num1 = TextBox1.Text

TextBox1.Text = ""

op = "/"

TextBox2.Text = "/"

End Sub

Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click

num2 = TextBox1.Text

If op = "+" Then

TextBox1.Text = num1 + num2

ElseIf op = "-" Then

TextBox1.Text = num1 - num2

ElseIf op = "*" Then

TextBox1.Text = num1 * num2

ElseIf op = "/" Then

TextBox1.Text = num1 / num2

End If

End Sub
Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click

TextBox1.Text = ""

TextBox2.Text = ""

End Sub

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


TextBox1.TextChanged

End Sub

End Class
7. Write a program using sub procedure to display employee details.
Module employee
Dim firstname As String
Dim lastname As String
Dim id As Integer
Dim contact As Double
Dim age As Integer
Sub getdetails()
Console.WriteLine("Enter first name")
firstname = Console.ReadLine
Console.WriteLine("Enter last name")
lastname = Console.ReadLine
Console.WriteLine("Enter ID")
id = Console.ReadLine
Console.WriteLine("Enter Contact")
contact = Console.ReadLine
Console.WriteLine("Enter age")
age = Console.ReadLine
End Sub
Sub displaydata()
Console.WriteLine("Firstname:{0}", firstname)
Console.WriteLine("Lastname:{0}", lastname)
Console.WriteLine("ID:{0}", id)
Console.WriteLine("Contact:{0}", contact)
Console.WriteLine("Age:{0}", age)
End Sub
Sub main()
getdetails()
displaydata()
End Sub
8.Write a program to input N numbers into an array and sort them in descending order and display.
Imports System

Module Program
Sub Main()
Console.Write("Enter the number of elements: ")
Dim n As Integer = Convert.ToInt32(Console.ReadLine())
Dim arr(n - 1) As Integer
For i As Integer = 0 To n - 1
Console.Write("Enter element {0}: ", i + 1)
arr(i) = Convert.ToInt32(Console.ReadLine())
Next
For i As Integer = 0 To n - 2
For j As Integer = 0 To n - i - 2
If arr(j) < arr(j + 1) Then
' Swap the elements
Dim temp As Integer = arr(j)
arr(j) = arr(j + 1)
arr(j + 1) = temp
End If
Next
Next
Console.WriteLine("Sorted array in descending order:")
For i As Integer = 0 To n - 1
Console.Write(arr(i) & " ")
Next
Console.ReadLine()
End Sub
End Module

You might also like