50% found this document useful (4 votes)
4K views34 pages

VB.NET Calculator and Database Programs

The document describes a VB.net program to create a basic calculator application using windows forms. It includes an aim, algorithm, program code, windows form design, and output/result. The algorithm outlines 8 steps to write the program, including dragging buttons and a textbox, storing values in memory, performing operations like addition when buttons are clicked, and clearing the textbox. The program code implements the algorithm by handling button click events to perform the calculations and display results.

Uploaded by

Sabari Carouna
Copyright
© Attribution Non-Commercial (BY-NC)
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
50% found this document useful (4 votes)
4K views34 pages

VB.NET Calculator and Database Programs

The document describes a VB.net program to create a basic calculator application using windows forms. It includes an aim, algorithm, program code, windows form design, and output/result. The algorithm outlines 8 steps to write the program, including dragging buttons and a textbox, storing values in memory, performing operations like addition when buttons are clicked, and clearing the textbox. The program code implements the algorithm by handling button click events to perform the calculations and display results.

Uploaded by

Sabari Carouna
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 34

CALCULATOR

AIM:
To write a [Link] program using windows application to perform calculator operation.

ALGORITHM:
Step 1: Start the program. Step 2: drag a textbox and eighteen buttons from the toolbox . Step 3: Memory button used to store the current value in the textbox. Step 4: Recall button used to display the stored value in the textbox. Step 5: cancel button used to clear the textbox. Step 6: To perform addition, subtraction, multiply and division operation button 0 to 9 used as a operand by using +,-,*,/ button . Step 7: if you click = button, then it shows the output in the textbox. Step 8: Stop the program.

PROGRAM:
Public Class Form1 Dim operand1 As Double Dim operand2 As Double Dim [operator] As String Private Sub Button1_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link], [Link], [Link], [Link], [Link], [Link], [Link], [Link], [Link], [Link], [Link], [Link] [Link] = [Link] & [Link] End Sub Private Sub Button10_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] If InStr([Link], ".") > 0 Then Exit Sub Else [Link] = [Link] & "." End If End Sub Private Sub Button13_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] operand1 = Val([Link]) [Link] = "" [Link]() [operator] = "+" End Sub Private Sub Button14_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] operand1 = Val([Link]) [Link] = [Link]() [operator] = "-" End Sub Private Sub Button15_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] operand1 = Val([Link]) [Link] = "" [Link]() [operator] = "*" End Sub Private Sub Button16_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] operand1 = Val([Link]) [Link] = ""

[Link]() [operator] = "/" End Sub Private Sub Button17_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Dim result As Double operand2 = Val([Link]) Select Case ([operator]) Case "+" result = operand1 + operand2 MsgBox(result) [Link] = result Case "-" result = operand1 - operand2 MsgBox(result) [Link] = result Case "*" result = operand1 * operand2 MsgBox(result) [Link] = result Case "/" result = operand1 / operand2 MsgBox(result) [Link] = result End Select [Link] = result End Sub Private Sub Button12_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] [Link] = "" End Sub End Class

WINDOWS FORM:

OUTPUT:

RESULT:
Thus the [Link] program using windows application to perform calculator operation has been executed and the output is verified successfully.

EMPLOYEE DATABASE

AIM:
To implement and create an database application of student details using Visual [Link].

ALGORITHM:
Step1: Start the program. Step 2: Choose a windows form application in VisualBasic Step 3: Design the form as per the form design Step 4: Write the code for all the required events Step 5: Create a database for storing all the required data Step 6: Compile the program using build command Step 7: Run the program using start debugging command. Step8: Stop the program.

WINDOW FORM:

PROGRAM:
Imports [Link] Public Class Form1 Dim con As New OleDbConnection Dim com As New OleDbCommand Dim da As New OleDbDataAdapter Dim rd As OleDbDataReader Dim dps, sql As String Private Sub Form1_Load(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] dps= "Provider=[Link].12.0;Data Source=F:\abinaya01\empdetails\[Link]" [Link] = dps [Link]() End Sub Private Sub Button1_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] sql = "insert into empo (name,age) values ('" & [Link] & "'," & [Link] & ")" [Link] = New OleDbCommand(Sql, con) [Link]() MsgBox("inserted to db") [Link] = "" [Link] = "" [Link] = "" End Sub Private Sub Button2_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] sql = "update empo set salary = " & [Link] & "where name = '" & [Link] & "'" [Link] = New OleDbCommand(sql, con) [Link]() MsgBox("updated to db") [Link] = "" [Link] = "" [Link] = "" End Sub Private Sub Button3_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] sql = "delete from empo where name='" & [Link] & "'" [Link] = New OleDbCommand(sql, con) [Link]() MsgBox("deleted from db") [Link] = "" [Link] = "" [Link] = "" End Sub

Private Sub Button4_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] sql = "select age,salary from empo where name = '" & [Link] & "'" [Link] = sql [Link] = con rd = [Link]() If [Link] Then [Link] = [Link](0) [Link] = [Link](1) [Link]() End If End Sub Private Sub Button5_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] [Link] = "" [Link] = "" [Link] = "" End Sub End Class

OUTPUT:

RESULT:
Thus employee details application has been implemented and executed successfully.

MDI APPLICATION Aim: To write a [Link] program using windows application to implement multiple document interface.

Algorithm: 1. Create three forms as form1, form2 and form3. 2. In form1, drag two labels, textboxes and button. 3. In form2 and form3, drag two labels. 4. If you click button1 in the form1, then it shows form2 with content in the textbox1. 5. If you click button2 in the form1, then it shows form3 with content in the textbox2.

PROGRAM CODE: Public Class Form1 Private Sub Button1_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Dim a As New Form2 [Link]() End Sub Private Sub Button2_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Dim a1 As New Form3 [Link]() End Sub End Class Public Class Form2 Private Sub Form2_Load(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] [Link] = [Link] End Sub End Class Public Class Form3 Private Sub Form3_Load(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] [Link] = [Link] End Sub End Class

OUTPUT:

RESULT: Thus the Project to perform MDI Operation in [Link] using the concept of Window Forms was successfully implemented and executed.

MENU CONTROLS

Aim: To develop a Project to perform menu controls Operation in [Link] using the concept of Window Forms. Algorithm: 1. Drag the menustrip, savedialog, opendialog, fontdialog and a textbox. 2. In textbox, select the multiline. 3. Create file, edit, help menu and also new, open, save, close, cut, copy, paste, font, about option using menustrip tool. 4. In file menu, open a new file using new option, open a file using open option, save a file using save option, close the form using close option. 5. In edit menu, cut the content using cut option, copy the content using copy option, copied content will be paste by using paste option, change the font of the content [Link] help menu, about is used to display the message.

PROGRAM: Public Class Form1 Private Sub NewToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] [Link] = "" End Sub Private Sub OpenToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] [Link]() If [Link] = "" Then Exit Sub End If Dim tmp As String [Link](1, [Link], [Link]) Do While Not [Link](1) tmp = tmp & [Link](1) If Not EOF(1) Then End If Loop [Link]() [Link] = tmp End Sub Private Sub SaveToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] [Link]() If [Link] = "" Then Exit Sub End If [Link](1, [Link], [Link]) [Link](1, [Link]) [Link]() End Sub Private Sub CloseToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] End End Sub Private Sub CutToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] [Link] = " " End Sub Private Sub CopyToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] [Link]([Link]) End Sub

Private Sub PasteToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] [Link] = [Link] End Sub Private Sub FontToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] [Link]() [Link] = [Link] End Sub Private Sub AboutToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] MsgBox("this is [Link]") End Sub End Class

OUTPUT:

RESULT: Thus the Project to perform Menu controls Operation in [Link] using the concept of Window Forms was successfully implemented and executed.

NOTEPAD Aim: To develop a Project to perform Notepad Operation in [Link] using the concept of Window Forms. Algorithm: 1. Create a form to display the text using text box. 2. In the form place rich text box to display the text. 3. Using menu strip, create menus such as New, Open, Save, Save as, Print, Exit, Cut, Copy, Paste, Find etc. 4. Add open dialog, save dialog, font dialog, to the form which is used to show the Open, Save dialog box. 5. Write a necessary coding for the menus. 6. Execute the program.

PROGRAM: Public Class Form1 Private Sub NewToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] If [Link] = True Then Dim x As Integer = MsgBox("Do you want to save the modified document ?", [Link]) If x = vbYes Then [Link]() Else [Link] = "Untitled" [Link]() End If [Link] = "Untitled" [Link]() End If End Sub Private Sub OpenToolStripMenuItem_Click(ByVal sender As [Link], ByVal e [Link]) Handles [Link] Try Dim dlg As OpenFileDialog = New OpenFileDialog [Link] = "Open" [Link] = "Rich Text Files (*.rtf|*.rtf" If [Link]() = [Link] Then [Link]([Link]) End If Catch ex As Exception : End Try End Sub Private Sub SaveToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim dlg As SaveFileDialog = New SaveFileDialog [Link] = "Save" [Link] = "Rich Text Files(*.rtf)|*.rtf" If [Link]() = [Link] Then [Link]([Link], [Link]) End If Catch ex As Exception : End Try End Sub As

Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Try Dim dlg As SaveFileDialog = New SaveFileDialog [Link] = "Save As" [Link] = "Rich Text Files(*.rtf)|*.rtf" If [Link]() = [Link] Then [Link]([Link], [Link]) End If Catch ex As Exception : End Try End Sub Private Sub PrintToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] [Link]() End Sub Private Sub ExitToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] 'exit the program End End Sub Private Sub CutToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] [Link]() End Sub Private Sub CopyToolStripMenuItem_Click(ByVal sender As [Link], ByVal e [Link]) Handles [Link] [Link]() End Sub Private Sub PasteToolStripMenuItem_Click(ByVal sender As [Link], ByVal e [Link]) Handles [Link] [Link]() End Sub As

As

Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] [Link]() End Sub Private Sub UndoToolStripMenuItem_Click(ByVal sender As [Link], ByVal e [Link]) Handles [Link] If [Link] Then As

[Link]() End If End Sub Private Sub RedoToolStripMenuItem_Click(ByVal sender As [Link], ByVal e [Link]) Handles [Link] [Link]() End Sub Private Sub FontToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] [Link]() [Link] = [Link] End Sub Private Sub FindToolStripMenuItem_Click(ByVal sender As [Link], ByVal e As [Link]) Handles [Link] Dim a As String Dim b As String a = InputBox("Enter text to be found") b = InStr([Link], a) If b Then [Link]() [Link] = b - 1 [Link] = Len(a) Else MsgBox("Text not found.") End If End Sub End Class As

OUTPUT:

RESULT: Thus the Project to perform Notepad Operation in [Link] using the concept of Window Forms was successfully implemented and executed.

You might also like