Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Calculator

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

CALCULATOR

AIM: To write an application program to perform calculator using MS Visual Studio 2008.

REQUIREMENT SPECIFICATION: Operating System : Windows XP. Software : Microsoft Visual Studio 2008.

PROCEDURE: 1.In Microsoft visual studio 2008 open the visual basic project type and then choose the window form application. 2.Place the needed command buttons and add a Textbox in the form. a) Textbox is used to display the input and output. b) Command buttons are used for giving input such as numbers from 0 to 9 and certain symbols like +, -, *, / etc. 3.Clear buttons is used to clear the input given. 4.The necessary coding are write. 5.End to execuit the program.

PROGRAM CODE: Form 1: Calculator Public Class frmcalculator Dim Operand1 As Double Dim Operand2 As Double Dim [Operator] As String Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click, btn2.Click, btn3.Click, btn4.Click, btn5.Click, btn6.Click, btn7.Click, btn8.Click, btn9.Click, btnzero.Click txtsource.Text = txtsource.Text & sender.text End Sub Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click txtsource.Text = "" End Sub Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click Operand1 = Val(txtsource.Text) txtsource.Text = "" txtsource.Focus() [Operator] = "+" End Sub

Private Sub btndecimal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndecimal.Click If InStr(txtsource.Text, ".") > 0 Then Exit Sub Else txtsource.Text = txtsource.Text & "." End If End Sub Private Sub btnequals_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnequals.Click Dim Result As Double Operand2 = Val(txtsource.Text) 'If [Operator] = "+" Then 'Result = Operand1 + Operand2 'ElseIf [Operator] = "-" Then 'Result = Operand1 - Operand2

'ElseIf [Operator] = "/" Then 'Result = Operand1 / Operand2 'ElseIf [Operator] = "*" Then 'Result = Operand1 * Operand2 'End If Select Case [Operator] Case "+" Result = Operand1 + Operand2 MsgBox(Result.ToString("#,###.00"), MsgBoxStyle.Information, "Result") txtsource.Text = Result.ToString("#,###.00") Case "-" Result = Operand1 - Operand2 MsgBox(Result.ToString("#,###.00"), MsgBoxStyle.Information, "Result") txtsource.Text = Result.ToString("#,###.00") Case "/" Result = Operand1 / Operand2 MsgBox(Result.ToString("#,###.00"), MsgBoxStyle.Information, "Result") txtsource.Text = Result.ToString("#,###.00") Case "*" Result = Operand1 * Operand2 MsgBox(Result.ToString("#,###.00"), MsgBoxStyle.Information, "Result") txtsource.Text = Result.ToString("#,###.00") End Select txtsource.Text = Result.ToString("#,###.00") End Sub Private Sub btnminus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnminus.Click Operand1 = Val(txtsource.Text) txtsource.Text = "" txtsource.Focus() [Operator] = "-" End Sub Private Sub btnmultiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmultiply.Click Operand1 = Val(txtsource.Text) txtsource.Text = "" txtsource.Focus() [Operator] = "*" End Sub

Private Sub btndivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndivide.Click Operand1 = Val(txtsource.Text) txtsource.Text = "" txtsource.Focus() [Operator] = "/" End Sub Private Sub btnaddminus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnaddminus.Click txtsource.Text = -1 * txtsource.Text End Sub Private Sub btnx_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnx.Click Dim convert As Single If txtsource.Text <> 0 Then convert = 1 / Val(txtsource.Text) txtsource.Text = convert End If End Sub Private Sub frmcalculator_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown If e.KeyCode = Keys.Enter Then Call btnequals_Click(sender, e) End If End Sub End Class

FORM DESIGN:

RESULT: Thus the calculator have been designed using Visual Studio and the Output have been executed successfully.

EMPLOYEE DETAILS

AIM: To write an application program for employee information system using window form application. REQUIREMENT SPECIFICATION: OPERATING SYSTEM: Windows XP. SOFTWARE: Microsoft Visual Studio 2008. ENVIRONMENT SPECIFICATION: FRONT END: Microsoft Visual Studio BACK END: Microsoft access PROBLEM DESCRIPTION: The employee information system includes the login form and the employee details from. The login Form is used to authenticate the user. the employee details form is used to insert, update, delete and search the records using the employee id DATABASE DESIGN: LOGIN TABLE: Field Name User Name Password EMP INFO TABLE: Field Employee Id FName LName Designation Salary Number Text Text Text text Data type Text Text Data Type

PROCEDURE: 1.Open the window form application in visual basic project type. 2. In the admin form place two buttons for the login and exit. 3. In the login form place two textbox, labels and buttons. 4. In the login form load event connect the database to the form. 5. In the signin button write the code for to compare the data entered in text box with the database if it is equal go to employee detail form. 6. In the employee detail form the insert, delete, serach and update operation have been carried out. INSERT: a) Insert the employee ID, firstname, lastname, designation and salary. b) Using the insert query , the datas are inserted in the database. c) Display the message box when the data is inserted successfully. DELETE: a) Enter the employee id and click the search button. b) The details will be displayed in the text boxes. c) Press delete buton , the delete query is used to delete the entier record using the employee Id. d) Display the message box when the data is successfully deleted. SHOW: a) When the show button is clicked show employee form opens. b) The data grid control is added and the data base is linked to it. c) It displays all the data in the data grid window. UPDATE: a) Enter the employee id and press search button. b) Then edit the datas for change and press update button. c) The update query is used to update the datas in the database using the employeeID. d) Display if the data is updated are generate an error message.

PROGRAM CODE: From 1 : Admin Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Form2.Show() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click End End Sub End Class Form 2 : Login Form imports System.Data.OleDb Public Class Form2 Public Con As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\Documents and Settings\Kish\My Documents\Visual Studio 2008\Projects\New Folder\employee1.mdb;Persist Security Info=False") Public Dad As OleDbDataAdapter Public Drd As OleDbDataReader Public Cmd As OleDbCommand Public Dst = New DataSet Public CurrentRow As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim SearchUS As String Dim SearchPW As String Dim i, j As Integer SearchUS = TextBox1.Text SearchPW = TextBox2.Text j = Dst.Tables("employee").Rows.Count - 1 i=0 While i <> j + 1 If SearchUS = Dst.Tables("employee").Rows(i)(0) And SearchPW = Dst.Tables("employee").Rows(i)(1) Then Form3.Show Exit While ElseIf i = j Then Clear() MsgBox("Check your Username and Password!!!") Exit While

End If i += 1 End While CurrentRow = i End Sub Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load CurrentRow = 0 Con.Open() Dad = New OleDbDataAdapter("SELECT * FROM login ", Con) Dad.Fill(Dst, "employee") Con.Close() End Sub Private Sub ShowData(ByVal CurrentRow) Try TextBox1.Text = Dst.Tables("employee").Rows(CurrentRow)(0) TextBox2.Text = Dst.Tables("employee").Rows(CurrentRow)(1) Catch ex As Exception End Try End Sub Private Sub Clear() TextBox1.Text = "" TextBox2.Text = "" End Sub End Class Form 3 : Employee Details imports System.Data.OleDb Public Class Form3 Public Con As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\Documents and Settings\Kish\My Documents\Visual Studio 2008\Projects\New Folder\employee1.mdb;Persist Security Info=False") Public Dad As OleDbDataAdapter Public Drd As OleDbDataReader Public Cmd As OleDbCommand Public Dst = New DataSet Public CurrentRow As Integer Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load CurrentRow = 0 Con.Open()

Dad = New OleDbDataAdapter("SELECT * FROM empinfo ORDER BY Id", Con) Dad.Fill(Dst, "employee") Con.Close() End Sub Private Sub First_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles First.Click CurrentRow = 0 ShowData(CurrentRow) End Sub Private Sub ShowData(ByVal CurrentRow) Try Id.Text = Dst.Tables("employee").Rows(CurrentRow)("Id") FName.Text = Dst.Tables("employee").Rows(CurrentRow)("FName") LName.Text = Dst.Tables("employee").Rows(CurrentRow)("LName") Designation.Text = Dst.Tables("employee").Rows(CurrentRow)("Designation") Salary.Text = Dst.Tables("employee").Rows(CurrentRow)("Salary") Catch ex As Exception End Try End Sub Private Sub Previous_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Previous.Click If CurrentRow <> 0 Then CurrentRow -= 1 ShowData(CurrentRow) Else MsgBox("First Record is Reached!!!") End If End Sub Private Sub Forward_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Forward.Click If CurrentRow = Dst.Tables("employee").Rows.Count - 1 Then MsgBox("Last Record is Reached!!!") Else CurrentRow += 1 ShowData(CurrentRow) End If End Sub Private Sub Last_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Last.Click CurrentRow = Dst.Tables("employee").Rows.Count - 1 ShowData(CurrentRow)

End Sub Private Sub Clear() Id.Text = "" FName.Text = "" LName.Text = "" Designation.Text = "" Salary.Text = "" End Sub Private Sub Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Search.Click Dim SearchId As Integer Dim i, j As Integer If CheckId() = False Then MsgBox("Integer Value Required!!!") Exit Sub End If Try SearchId = Id.Text j = Dst.Tables("employee").Rows.Count - 1 i=0 While i <> j + 1 If SearchId = Dst.Tables("employee").Rows(i)("Id") Then ShowData(i) Exit While ElseIf i = j Then Clear() MsgBox("Record Not Found!!!") ShowData(CurrentRow) Exit While End If i += 1 End While CurrentRow = i Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click Dim Str As String If CheckId() = False Then MsgBox("Id : Integer Value Required !!!") Exit Sub

ElseIf IsIdExist() = True Then MsgBox("Id : Id is already exist. Please choose another one..... For help please consider the data by clicking on ""Show Data"" Button") Exit Sub ElseIf CheckFName() = False Then MsgBox("FName : Only Characters Allowed!!!") Exit Sub ElseIf CheckLName() = False Then MsgBox("LName : Only Characters Allowed!!!") Exit Sub ElseIf CheckDesignation() = False Then MsgBox("Designation : Only Characters Allowed!!!") Exit Sub ElseIf CheckSalary() = False Then MsgBox("Salary : Integer Value Required !!!") Exit Sub End If Try Str = "insert into empinfo values(" Str += Id.Text.Trim() Str += "," Str += """" & FName.Text.Trim() & """" Str += "," Str += """" & LName.Text.Trim() & """" Str += "," Str += """" & Designation.Text.Trim() & """" Str += "," Str += Salary.Text.Trim() Str += ")" Con.Open() Cmd = New OleDbCommand(Str, Con) Cmd.ExecuteNonQuery() Dst.Clear() Dad = New OleDbDataAdapter("SELECT * FROM empinfo ORDER BY Id", Con) Dad.Fill(Dst, "employee") MsgBox("Record inserted successfully...") Con.Close() Catch ex As Exception MessageBox.Show("Could Not Insert Record!!!") MsgBox(ex.Message & " - " & ex.Source) Con.Close() End Try End Sub ' To select the data in First Name Field

Private Sub FName_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles FName.GotFocus FName.SelectAll() End Sub ' To select the data in Last Name Field Private Sub LName_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles LName.GotFocus LName.SelectAll() End Sub ' To select the data in Designation Field Private Sub Designation_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Designation.GotFocus Designation.SelectAll() End Sub ' To select the data in Salary Field Private Sub Salary_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Salary.GotFocus Salary.SelectAll() End Sub ' To update the records in database Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click If CheckId() = False Then MsgBox("Id : Integer Value Required !!!") Exit Sub ElseIf CheckFName() = False Then MsgBox("FName : Only Characters Allowed!!!") Exit Sub ElseIf CheckLName() = False Then MsgBox("LName : Only Characters Allowed!!!") Exit Sub ElseIf CheckDesignation() = False Then MsgBox("Designation : Only Characters Allowed!!!") Exit Sub ElseIf CheckSalary() = False Then MsgBox("Salary : Integer Value Required !!!") Exit Sub End If Try Dim Str As String Str = "update empinfo set FName=" Str += """" & FName.Text & """" Str += " where Id=" Str += Id.Text.Trim() Con.Open() Cmd = New OleDbCommand(Str, Con)

Cmd.ExecuteNonQuery() Con.Close() Con.Open() Str = "update empinfo set LName=" Str += """" & LName.Text & """" Str += " where Id=" Str += Id.Text.Trim() Cmd = New OleDbCommand(Str, Con) Cmd.ExecuteNonQuery() Con.Close() Con.Open() Str = "update empinfo set Designation=" Str += """" & Designation.Text & """" Str += " where Id=" Str += Id.Text.Trim() Cmd = New OleDbCommand(Str, Con) Cmd.ExecuteNonQuery() Con.Close() Con.Open() Str = "update empinfo set Salary=" Str += """" & Salary.Text & """" Str += " where Id=" Str += Id.Text.Trim() Cmd = New OleDbCommand(Str, Con) Cmd.ExecuteNonQuery() Con.Close() Dst.Clear() Dad = New OleDbDataAdapter("SELECT * FROM empinfo ORDER BY Id",Con) Dad.Fill(Dst, "employee") MsgBox("Updated Successfully...") Catch ex As Exception MsgBox(ex.Message & "," & ex.Source) End Try End Sub Private Function CheckId() Try If IsNumeric(Id.Text) = False Then ShowData(CurrentRow) Id.Focus() Return False End If Catch ex As Exception End Try Return True End Function

' To check the data in salary field : whether numeric or not Private Function CheckSalary() Try If IsNumeric(Salary.Text) = False Then ShowData(CurrentRow) Salary.Focus() Return False End If Catch ex As Exception End Try Return True End Function ' To check the data in First Name Field : whether a string or not Private Function CheckFName() Try If FName.Text = "" Or ValidateString(FName.Text) = False Then ShowData(CurrentRow) FName.Focus() Return False End If Catch ex As Exception End Try Return True End Function ' To check the data in Last Name Field : whether a string or not Private Function CheckLName() Try If LName.Text = "" Or ValidateString(LName.Text) = False Then ShowData(CurrentRow) LName.Focus() Return False End If Catch ex As Exception End Try Return True End Function ' To check the data in Designation Field : whether a string or not Private Function CheckDesignation() Try If Designation.Text = "" Or ValidateString(Designation.Text) = FalseThen ShowData(CurrentRow) Designation.Focus() Return False End If Catch ex As Exception End Try

Return True End Function ' To check the string for numeric values Private Function ValidateString(ByVal Str) Dim i As Integer Dim ch As Char i=0 While i < Str.Length() ch = Str.Chars(i) If IsNumeric(ch) = True Then Return False End If i += 1 End While Return True End Function Private Function IsIdExist() Dim Str, Str1 As String Dim i As Integer Str = Id.Text i=0 While i <> Dst.Tables("employee").rows.count Str1 = Dst.Tables("employee").Rows(i)("Id") If Str = Str1 Then Return True End If i += 1 End While Return False End Function ' To show the data in the datagridview Private Sub button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button4.Click Me.Hide() Form4.Show() End Sub Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button3.Click Dim Str As String If CheckId() = False Then MsgBox("Id : Integer Value Required!!!") Exit Sub End If Try Str = "delete from empinfo where id="

Str += Id.Text.Trim Con.Open() Cmd = New OleDbCommand(Str, Con) Cmd.ExecuteNonQuery() Dst.clear() Dad = New OleDbDataAdapter("SELECT * FROM empinfo ORDER BY Id", Con) Dad.Fill(Dst, "employee") MsgBox("Record deleted successfully...") If CurrentRow > 0 Then CurrentRow -= 1 ShowData(CurrentRow) End If Con.Close() Catch ex As Exception MessageBox.Show("Could Not delete Record!!!") MsgBox(ex.Message & " - " & ex.Source) Con.Close() End Try End Sub Private Sub formclose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles formclose.Click End End Sub End Class Form 4 : Show Employee Public Class Form4 Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'Employee1DataSet.empinfo' table. You can move, or remove it, as needed. Me.EmpinfoTableAdapter.Fill(Me.Employee1DataSet.empinfo) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Close() Form3.Show() End Sub End Class

FORM DESIGN:

RESULT: Thus the application program to perform employee information using window form application have been designed using Visual Studio and the Output has been executed successfully.

MDI APPLICATION AIM: To Design a MDI application using Visual Studio REQUIREMENT SPECIFICATION: Operating System : Windows XP. Software : Microsoft Visual Studio 2008. PROCEDURE: 1.Open the window form appliation in visual basic project type. 2. In the From 1 change the IsMDIparent Property to True. 3. Then add three more forms to the MDI from. 4. Add menus for the project like alarm clock, progress bar, windows. 5. Create Object for the froms and set the froms as child forms. 6 in the alarm form add labels, button, radio button and text box, timer. 7. Then add respective coding to the button in alarm clock from. 8.In progress bar form add Progress bar, timer and button. 9. Then add respective coding to the button. 10. In picture box form add picture box, and two buttons. 11. Write the respective coding to load the image and strech the image. 12. Then in the window menu create menus such as horizontal, vertical and cascade. 13. write the respective coding to arrange the child forms in order. 14. execute the program .

PROGRAM CODE: Form 1 : MDI Parent Window Public Class Form1 Private Sub CAscadeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CAscadeToolStripMenuItem.Click Me.LayoutMdi(MdiLayout.Cascade) End Sub Private Sub HorizontalToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HorizontalToolStripMenuItem.Click Me.LayoutMdi(MdiLayout.TileHorizontal) End Sub Private Sub VerticalToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VerticalToolStripMenuItem.Click Me.LayoutMdi(MdiLayout.TileVertical) End Sub Private Sub Child1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Child1ToolStripMenuItem.Click ' Alarm Clock Dim child1 As New Form2 child1.MdiParent = Me child1.Show() End Sub Private Sub Child2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Child2ToolStripMenuItem.Click 'Progress Bar Dim child2 As New Form3 child2.MdiParent = Me child2.Show() End Sub Private Sub Child3ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Child3ToolStripMenuItem.Click 'Picture Box

Dim child3 As New Form4 child3.MdiParent = Me child3.Show() End Sub Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click End End Sub End Class Form 2: Alarm Clock Public Class Form2 Dim blnAlarm As Boolean = False Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Label1.Text = TimeOfDay If TextBox1.Text <> "" And TextBox2.Text <> "" And _ TextBox3.Text <> "" Then Dim AlarmTime = New DateTime(Today.Year, Today.Month, _ Today.Day, CInt(TextBox1.Text), CInt(TextBox2.Text), _ CInt(TextBox3.Text)) If Now > AlarmTime And blnAlarm Then Beep() End If End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Timer1.Enabled = True End Sub Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged If RadioButton1.Checked Then blnAlarm = True End If End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged If RadioButton1.Checked Then blnAlarm = False End If End Sub End Class Form 3: Progress bar Public Class Form3 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Timer1.Enabled = True End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick ProgressBar1.Value += 1 If ProgressBar1.Value = ProgressBar1.Maximum Then Timer1.Enabled = False End If End Sub End Class Form 4: Picture Box Public Class Form4 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click PictureBox1.Image = Image.FromFile("F:\BackUp data\Downloads\Wallpapers\Focus.jpg") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage PictureBox1.ClientSize = New Size(300, 100) End Sub End Class

FORM DESIGN:

RESULT: Thus the mdi application have been designed and output is verified sucessfully.

NOTEPAD

AIM: To write an application program to perform notepad using MS Visual Studio 2008.

REQUIREMENT SPECIFICATION: Operating System : Windows XP. Software : Microsoft Visual Studio 2008.

PROCEDURE: 1. In Microsoft visual studio 2008 open the visual basic project type and then choose the window form application. 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 CODE: Public Class Form1 Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click If RichTextBox1.Modified = True Then Dim x As Integer = MsgBox("Do you want to save the modified document ?", MsgBoxStyle.YesNo) If x = vbYes Then SaveToolStripMenuItem.PerformClick() Else Me.Text = "Untitled" RichTextBox1.Clear() End If Me.Text = "Untitled" RichTextBox1.Clear() End If End Sub Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click Try Dim dlg As OpenFileDialog = New OpenFileDialog dlg.Title = "Open" dlg.Filter = "Rich Text Files (*.rtf|*.rtf" If dlg.ShowDialog() = System.Windows.Forms.DialogResult.OK Then RichTextBox1.LoadFile(dlg.FileName) End If Catch ex As Exception : End Try End Sub Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click Try Dim dlg As SaveFileDialog = New SaveFileDialog dlg.Title = "Save" dlg.Filter = "Rich Text Files(*.rtf)|*.rtf" If dlg.ShowDialog() = System.Windows.Forms.DialogResult.OK Then RichTextBox1.SaveFile(dlg.FileName, RichTextBoxStreamType.RichText) End If Catch ex As Exception : End Try End Sub Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveAsToolStripMenuItem.Click

Try Dim dlg As SaveFileDialog = New SaveFileDialog dlg.Title = "Save As" dlg.Filter = "Rich Text Files(*.rtf)|*.rtf" If dlg.ShowDialog() = System.Windows.Forms.DialogResult.OK Then RichTextBox1.SaveFile(dlg.FileName, RichTextBoxStreamType.RichText) End If Catch ex As Exception : End Try End Sub Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem.Click PrintDialog1.ShowDialog() End Sub Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click 'exit the program End End Sub Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripMenuItem.Click RichTextBox1.Clear() End Sub Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click RichTextBox1.Copy() End Sub Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click RichTextBox1.Paste() End Sub Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllToolStripMenuItem.Click RichTextBox1.SelectAll() End Sub Private Sub UndoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UndoToolStripMenuItem.Click If RichTextBox1.CanUndo Then RichTextBox1.Undo() End If

End Sub Private Sub RedoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RedoToolStripMenuItem.Click RichTextBox1.Redo() End Sub Private Sub FontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FontToolStripMenuItem.Click FontDialog1.ShowDialog() RichTextBox1.Font = FontDialog1.Font End Sub Private Sub FindToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FindToolStripMenuItem.Click Dim a As String Dim b As String a = InputBox("Enter text to be found") b = InStr(RichTextBox1.Text, a) If b Then RichTextBox1.Focus() RichTextBox1.SelectionStart = b - 1 RichTextBox1.SelectionLength = Len(a) Else MsgBox("Text not found.") End If End Sub End Class

FORM DESIGN:

RESULT: Thus the Notepad application using window form application have been designed and executed successfully.

EVENT REGISTRATION FORM

AIM: To design a window form for event registration using MS Visual Studio 2008.

REQUIREMENT SPECIFICATION: Operating System : Windows XP. Software : Microsoft Visual Studio 2008.

PROBLEM DESCRIPTION: The event registration form is used to register the participant in various events and gets his personal details and credit card information

PROCEDURE: 1.In Microsoft visual studio 2008 open the visual basic project types and then choose the window form application. 2.Place the controls on the form. 3.Write the coding for the command button such that each and every textbox & combo box should be checked whether the value is given or not. 4.Finally display the message box registered successfully. If all the values are entered in the respective textboxes.

PROGRAM CODE: Imports System.Text.RegularExpressions Public Class Form1 Dim a, b As Integer Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged TextBox1.Text = 200 a = TextBox1.Text End Sub Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged TextBox2.Text = ComboBox1.Text * 150 b = TextBox2.Text TextBox3.Text = a + b End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If (email.Text = "" OrElse Fname.Text = "" OrElse Lname.Text = "" OrElse Address1.Text = "" OrElse Address2.Text = "" OrElse city.Text = "" OrElse Mobile.Text = "" OrElse Credit.Text = "") Then ' display popup box MessageBox.Show("Please fill in all fields", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Return End If If Not Regex.Match(email.Text, "^[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z_+])*@([0-9azA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9}$").Success Then ' city was incorrect MessageBox.Show("Invalid EMAIL ID ", "Message") city.Focus() Return End If If Not Regex.Match(Fname.Text, "^[A-Z][a-zA-Z]*$").Success Then ' last name was incorrect MessageBox.Show("Invalid First Name", "Message") Fname.Focus() Return End If ' if address1 format invalid show message If Not Regex.Match(Address1.Text, "^[0-9]+\s+([a-zA-Z]" & "+|[a-zA-Z]+\s[azA-Z]+)$").Success Then ' address was incorrect MessageBox.Show("Invalid Address", "Message") Address1.Focus()

Return End If ' if city format invalid show message If Not Regex.Match(city.Text, "^([a-zA-Z]+|[a-zA-Z]" & "+\s[a-zAZ]+)$").Success Then ' city was incorrect MessageBox.Show("Invalid City", "Message") city.Focus() Return End If ' if phone number format invalid show message If Not Regex.Match(Mobile.Text, "^\d{10}$").Success Then 'phone was incorrect MessageBox.Show("Invalid Phone Number", "Message") Mobile.Focus() Return End If If Not Regex.Match(Credit.Text, "^\d{5}$").Success Then 'phone was incorrect MessageBox.Show("Invalid Credit card Number", "Message") Credit.Focus() Return End If ' information is valid, signal user and exit application MessageBox.Show("Thank you for registering!", MessageBoxButtons.OK, MessageBoxIcon.Information) End Sub End Class "Information Correct",

FROM DESIGN:

RESULT: Thus the event registration using window form application have been designed and executed successfully.

ARITHMETIC OPERATIONS

AIM: To write an application program to perform arithmetic operations using MS Visual Studio 2008.

REQUIREMENT SPECIFICATION: Operating System : Windows XP. Software : Microsoft Visual Studio 2008.

PROCEDURE: 1.In Microsoft visual studio 2008 open the visual basic project type and then choose the window form application. 2.Place the needed command buttons and add a Textbox in the form. a) Textbox is used to display the input and output. b) Command buttons are used for giving input and perform operation such as addition, subtraction, multiplication and division. 3.Clear buttons is used to clear the input given. 4.The necessary coding are write. 5.End to execuit the program.

PROGRAM CODE: Module Module1 Sub Main() Dim intInput As Integer Dim number1 As Integer Dim number2, sum As Integer Console.Write("Please enter the first integer: ") number1 = Console.ReadLine() Console.Write("Please enter the second integer: ") number2 = Console.ReadLine() Do Console.Write("1.Addition") Console.Write("2.Subtraction") Console.Write("3.Multiplication") Console.Write("4.Division") Console.WriteLine("Enter your choice :") intInput = Val(Console.ReadLine()) Select Case intInput Case 1 Console.Write("Addition") sum = number1 + number2 Console.WriteLine("The sum is {0} ", sum) Case 2 Console.Write("Subtraction") sum = number1 - number2 Console.WriteLine("The subtracted value is {0}", sum) Case 3 Console.Write("Multiplication") sum = number1 * number2 Console.WriteLine("The Multiplied is {0}", sum) Case 4 Console.Write("Division") sum = number1 / number2 Console.WriteLine("The Divided value is {0}", sum) Case Else Console.WriteLine("only 4 options") End Select Loop While (intInput < 5) End Sub End Module

OUTPUT: Please enter the first integer: 12 Please enter the second integer: 10 1.Addition 2.Subtraction 3.Multuplication 4.Division Enter your choice: 1 The sum is 22 1.Addition 2.Subtraction 3.Multuplication 4.Division Enter your choice:2 The subtracted value is 2 1.Addition 2.Subtraction 3.Multuplication 4.Division Enter your choice:3 The Multiplied is 120 1.Addition 2.Subtraction 3.Multuplication 4.Division Enter your choice:4 The Divided value is 1 RESULT: Thus the application program to perform arithmetic operation have been designed using Visual Studio and the Output have been executed successfully.

You might also like