System Analysis and Design LAB RECORD-INFS -280/L Information Systems Department University of Nizwa, Sultanate of Oman
Table of Contents Task. No: Title Page Nos. Date 1) VB Text box and Message Button 3-6 2) VB Application to accept two numbers and to perform Simple Math-Arithmetic operations 3) 4) 5) 6) 7) 8) 9) 10) 11) LAB RECORD SAD-INFS-280/L Page 1
TASK- 1 VB Text box and Message Button Date: Objective: This VB program will ask the user to enter his/her name in the text box and gives the welcome message. Code: Public Class Welcome Private Sub Btnwelcome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnwelcome.Click MsgBox("Welcome to University of Nizwa " & urname.text) Output: LAB RECORD SAD-INFS-280/L Page 2
Date: Task2: VB Application to accept two numbers and to perform Simple Math-Arithmetic operations Objective: VB Application to accept two numbers and to perform Simple Math-Arithmetic operations such as Addition, Subtraction, Multiplication and Division. Code: Public Class MathCalculator Private Sub cmdsum_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles cmdsum.click Dim number1, number2, sum, difference, product, quotient As Single number1 = num1.text number2 = num2.text sum = number1 + number2 MsgBox("The Sum of the two given numbers is=> " & sum) Private Sub cmdexit_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles cmdexit.click MsgBox("Thank you, Do you want to exit?", MsgBoxStyle.OkOnly) Me.Close() Private Sub cmddifference_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles cmddifference.click Dim number1, number2, sum, difference, product, quotient As Single number1 = num1.text number2 = num2.text difference = number1 - number2 MsgBox("The Difference of the two given numbers is=> " & difference) Private Sub cmdproduct_click(byval sender As System.Object, ByV`al e As System.EventArgs) Handles cmdproduct.click Dim number1, number2, sum, difference, product, quotient As Single number1 = num1.text number2 = num2.text product = number1 * number2 MsgBox("The Product of the two given numbers is=> " & product) Private Sub cmdquotient_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles cmdquotient.click Dim number1, number2, sum, difference, product, quotient As Single number1 = num1.text number2 = num2.text quotient = number1 / number2 MsgBox("The Quotient of the two given numbers is=> " & quotient) LAB RECORD SAD-INFS-280/L Page 3
Output: LAB RECORD SAD-INFS-280/L Page 4
Date: Task3: VB Application to accept the marks and to calculate the Total, Percentage and Grade using Select..Case Control Structure LAB RECORD SAD-INFS-280/L Page 5
TASK- 4 VB Colour Play and Font Style Date: Objective: This VB program will ask the user to enter any text into a text box and format the font using the three checkboxes that represent bold, italic and underline and also to change the form Back colour using he Radio Buttons(Red/Green/Blue) chkbold txtformat chkitalics cmdformat chkunderline radred cmdcolour radgreen radblue Code Public Class VBColourPlay Private Sub cmdformat_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles cmdformat.click If ChkBold.Checked Then txtformat.font = New Font(txtformat.Font, txtformat.font.style Or FontStyle.Bold) Else txtformat.font = New Font(txtformat.Font, txtformat.font.style And Not FontStyle.Bold) End If If ChkItalics.Checked Then txtformat.font = New Font(txtformat.Font, txtformat.font.style Or FontStyle.Italic) Else txtformat.font = New Font(txtformat.Font, txtformat.font.style And Not FontStyle.Italic) LAB RECORD SAD-INFS-280/L Page 6
End If If ChkUnderline.Checked Then txtformat.font = New Font(txtformat.Font, txtformat.font.style Or FontStyle.Underline) Else txtformat.font = New Font(txtformat.Font, txtformat.font.style And Not FontStyle.Underline) End If Private Sub cmdcolour_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles cmdcolour.click : If RadioRed.Checked = True Then Me.BackColor = Color.Red Exit Sub ElseIf RadioGreen.Checked = True Then Me.BackColor = Color.Green Exit Sub ElseIf RadioBlue.Checked = True Then Me.BackColor = Color.Blue End If LAB RECORD SAD-INFS-280/L Page 7
TASK- 5 VB BODY MASS INDEX(BMI) CALCULATOR Date: Objective: This VB program will ask the user to enter his/her height in meters (M) and weight in Kilograms (Kg) into a text box and will calculate the BMI of the person. The output will display whether he/she is underweight/over-weight/ Obese accordingly. Code: Public Class VBBMI Private Sub cmdbmi_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles cmdbmi.click Dim height, weight, bmi As Single height = ht.text weight = wt.text bmi = (weight) / (Height ^ 2) lblbmi.text = bmi Select Case bmi Case 0 To 18.4 lblbs.text = "Under-Weight, Eat well!" Case 18.5 To 24.9 lblbs.text = "Normal-Weight, Maintain Your Diet!" Case 25 To 29.9 lblbs.text = "Over-Weight, Do Exercise Regularly!" Case Else lblbs.text = "you have Obesity, Do dieting and Exercise!" End Select Output: LAB RECORD SAD-INFS-280/L Page 8
TASK- 6: VB ATM Application using Multiple Forms Date: Objective: This VB program will ask the user to enter his/her Login Authentication details to enter in to the ATM control panel where user can do the Deposit /Withdrawal/Balance Enquiry/Sign-Out Operations. Code: LAB RECORD SAD-INFS-280/L Page 9
LAB RECORD SAD-INFS-280/L Page 10
Public Class WelcomeFRM Private Sub QUIT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QUIT.Click End Private Sub Login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Login.Click Me.Hide() LoginFrm.Show() Private Sub WelcomeFRM_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.TopMost = True Public Class LoginFrm Private Sub exitbtn_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles exitbtn.click Close() Private Sub Signin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Signin.Click If TextBox1.Text = "777" Then Me.Hide() ATMCPL.Show() Else MsgBox("Wrong pin number entered, TRY Again!!!") TextBox1.Text = "" TextBox1.Focus() End If Private Sub LoginFrm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.TopMost = True LAB RECORD SAD-INFS-280/L Page 11
Public Class ATMCPL Private Sub Deposit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Deposit.Click Depositfrm.Show() Me.Hide() Private Sub Balance_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Balance.Click Me.Close() Balancefrm.Show() Private Sub Withdraw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Withdraw.Click Withdrawfrm.Show() Me.Hide() Private Sub signout_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles signout.click MsgBox("Thank you for using the BANK Birkat-Al -Mouz ATM Service, GOOD DAY!!") Me.Hide() WelcomeFRM.Show() Private Sub ATMCPL_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.TopMost = True Public Class Depositfrm Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click Static Bal As Double = 0 Balance.Text = Balancefrm.NewBalance.Text MsgBox("you are about to deposit!!, are you sure?") Bal = Bal + TextBox1.Text Balance.Text = Bal Balancefrm.NewBalance.Text = Bal TextBox1.Text = "" Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click LAB RECORD SAD-INFS-280/L Page 12
MsgBox("You are cancelling the deposit Operation and Go to ATM Main Menu?") ATMCPL.Show() Me.Hide() Private Sub Depositfrm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.TopMost = True Public Class Withdrawfrm Private Sub CancelW_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CancelW.Click MsgBox("You are cancelling the withdraw Operation and Go to ATM Main Menu?") ATMCPL.Show() Me.Hide() Private Sub Withdrawfrm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.TopMost = True Balance.Text = Balancefrm.NewBalance.Text Private Sub OKWD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OKWD.Click Dim AvailBal As Double If TextBox1.Text <= Val(Balancefrm.NewBalance.Text) Then MsgBox("you are about to withdraw the above amount from your account!!, are you sure to proceed?") AvailBal = Val(Balancefrm.NewBalance.Text) - Val(TextBox1.Text) Balancefrm.NewBalance.Text = AvailBal Balance.Text = AvailBal TextBox1.Text = "" Else MsgBox("Sorry!,You have Insufficient Balance to proceed this Transaction!!, Please deposit some money") ATMCPL.Show() Me.Hide() End If Public Class Balancefrm Private Sub bkmenu_click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OKW.Click MsgBox("You are about to Proceed to ATM Main Menu?") LAB RECORD SAD-INFS-280/L Page 13
ATMCPL.Show() Me.Hide() Private Sub Balancefrm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.TopMost = True LAB RECORD SAD-INFS-280/L Page 14
TASK- 7: VB Web Browser Application Date: Objective: This VB Program will be developing a Personal Web Browser through which we can surf the desired Websites. Code: Public Class MyWebBrowser Private Sub Go_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Go.Click WebBrowser.Navigate(URLBox.Text) Private Sub MyWebBrowser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.TopMost = True LAB RECORD SAD-INFS-280/L Page 15
TASK- 8: VB File Operation Date: Objective: This VB Program will be developing a Text File Reader Utility Open, Read and display the Contents of a Simple Text File. Code Imports System.IO Public Class Form1 Private Sub Openread_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Openread.Click Dim FileReader As StreamReader Dim results As DialogResult results = OpenFileDialog.ShowDialog If results = DialogResult.OK Then FileReader = New StreamReader(OpenFileDialog.FileName) End If destination.text = FileReader.ReadToEnd() FileReader.Close() Private Sub Closebtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Closebtn.Click MsgBox("Do you wanna Close File Reader") End LAB RECORD SAD-INFS-280/L Page 16
OUTPUT LAB RECORD SAD-INFS-280/L Page 17
TASK- 9: VB Graphics Application Date: Objective: This VB Program is to create a Graphics application which will generate some geometrical shapes such as Rectangle, Circle, and Ellipse. Code Public Class GraphicsFRM Private Sub GraphicsFRM_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.TopMost = True Private Sub Rectangle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Rectangle.Click Dim mypen As Pen mypen = New Pen(Drawing.Color.Red, 5) Dim mygraphics As Graphics = Me.CreateGraphics mypen.dashstyle = Drawing.Drawing2D.DashStyle.Dot mygraphics.drawrectangle(mypen, 10, 100, 100, 50) Private Sub Ellipse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Ellipse.Click Dim mypen As Pen mypen = New Pen(Drawing.Color.Blue, 5) Dim mygraphics As Graphics = Me.CreateGraphics mygraphics.drawellipse(mypen, 150, 100, 200, 100) LAB RECORD SAD-INFS-280/L Page 18
Private Sub Circle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Circle.Click Dim mypen As Pen OutPut mypen = New Pen(Drawing.Color.aqua, 7) Dim mygraphics As Graphics = Me.CreateGraphics mygraphics.drawellipse(mypen, 400, 100, 100, 100) LAB RECORD SAD-INFS-280/L Page 19
TASK- 10: VB File Write Operation Date: Objective: This VB Program will be developing a Text File Writer Utility which can edit and save the Contents in to a Simple Text File. Code Imports System.IO Public Class writerfrm Private Sub Closebtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Closebtn.Click MsgBox("Do you wanna Close File Reader") End Private Sub writerfrm_load(byval sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.TopMost = True Private Sub savefile_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles savefile.click Dim FileWriter As StreamWriter Dim results As DialogResult results = SaveFileDialog1.ShowDialog If results = DialogResult.OK Then FileWriter = New StreamWriter(SaveFileDialog1.FileName, False) End If FileWriter.Write(destination.Text) FileWriter.Close() LAB RECORD SAD-INFS-280/L Page 20
LAB RECORD SAD-INFS-280/L Page 21