Program using visual basic.net
You will create a very simple two numbers calculator with save options; here is the specifications for the application. Create a form divided vertically in two halves with right and left panels 1- In the left panel you will create the following control, the label or the value of the control will be in "" and the type of the control will in [] a- "First Number" [textbox] b- "Second number" [texbox] c- "Result" [textbox] - read only d- "+" [push button] "-" [push button] "/" [push button] "*" [push button] f- "Save" [push button] "Display" [push button] 2- Operations The user will enter two numbers in the "First Number" and the "Second Number", then press the "+" for addition, "-" for subtraction, "*" multiplication and "/" the result will be displayed in the result [textbox], if the user clicked "[save]" then the operation can be displayed in the right panel when the user press [Display] Please note that the user can save up to 10 operations. Add "clear" [push button] on the right panel to clear the content, make sure that you trap all the errors and set the focus to the appropriate control after the error occurred - Make sure that the result contains the operations, I should see in the right panel something like this 1+1=2 1*2=2 and so on. - You must trap dived by Zero and a display a message to the user �Cannot Divide By Zero�, allow the user to renter another value
The main issue is figuring out how to limit the saved items added to the file to 10
Here's what I have so far:
Option Explicit On
Option Strict On
Option Infer Off
Public Class frmMain
Private Sub frmMain_Load(sender As Object, e As
EventArgs) Handles MyBase.Load
End Sub
Dim decNum1 As Decimal
Dim decNum2 As Decimal
Dim decNum3 As Decimal
Private Sub btnAdd_Click(sender As Object, e As
EventArgs) Handles btnAdd.Click
' accept input from text
box 1 and 2
Decimal.TryParse(txtNum1.Text, decNum1)
Decimal.TryParse(txtNum2.Text, decNum2)
' add num 1 and 2 and
display results
decNum3 = decNum1 +
decNum2
txtNum3.Text = decNum1
& " + " & decNum2 & " = " & decNum3
End Sub
Private Sub btnSubtract_Click(sender As
Object, e As EventArgs) Handles btnSubtract.Click
' accept input from text
box 1 and 2
Decimal.TryParse(txtNum1.Text, decNum1)
Decimal.TryParse(txtNum2.Text, decNum2)
' subtract num 2 from
num 1 and display results
decNum3 = decNum1 -
decNum2
txtNum3.Text = decNum1
& " - " & decNum2 & " = " & decNum3
End Sub
Private Sub btnMultiply_Click(sender As
Object, e As EventArgs) Handles btnMultiply.Click
' accept input from text
box 1 and 2
Decimal.TryParse(txtNum1.Text, decNum1)
Decimal.TryParse(txtNum2.Text, decNum2)
' multiply num 1 and
2 and display results
decNum3 = decNum1 *
decNum2
txtNum3.Text = decNum1
& " X " & decNum2 & " = " & decNum3
End Sub
Private Sub btnDivide_Click(sender As Object,
e As EventArgs) Handles btnDivide.Click
' accept input from text
box 1 and 2
Decimal.TryParse(txtNum1.Text, decNum1)
Decimal.TryParse(txtNum2.Text, decNum2)
' divide num 1 by num
2 and display results
Try
decNum3 = decNum1 / decNum2
Catch ex As
DivideByZeroException When decNum2 = 0
MessageBox.Show("Cannot divide by 0. Please enter a valid
number.")
txtNum2.Focus()
End Try
txtNum3.Text = decNum1
& " / " & decNum2 & " = " & decNum3
End Sub
Private Sub input_validation(sender As
Object, e As KeyPressEventArgs) Handles txtNum1.KeyPress,
txtNum2.KeyPress
' validate input is a
number 0-9
If (e.KeyChar < "0"
OrElse e.KeyChar > "9") AndAlso e.KeyChar <> "." AndAlso
e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
Private Sub btnClear_Click(sender As Object,
e As EventArgs) Handles btnClear.Click
' clears list box
lstOperations.Items.Clear()
End Sub
Private Sub btnSave_Click(sender As Object, e As
EventArgs) Handles btnSave.Click
' writes up to 10
operations to sequential access files
Dim outFile As
IO.StreamWriter
outFile =
IO.File.AppendText(“operations.txt”)
outFile.WriteLine(txtNum3.Text)
outFile.Close()
End Sub
Private Sub btnDisplay_Click(sender As
Object, e As EventArgs) Handles btnDisplay.Click
' reads operations from
a sequential access file and displays them in list box
' declare
variables
Dim inFile As
IO.StreamReader
Dim strOperation As
String
' clears previous
operations from list box
lstOperations.Items.Clear()
' determine wether
file exists
If
IO.File.Exists(“operations.txt”) Then
' open the file for input
inFile = IO.File.OpenText(“operations.txt”)
' process loop instructions until end of file
Do Until inFile.Peek = -1
' read operation
strOperation = inFile.ReadLine
' add operation to list box
lstOperations.Items.Add(strOperation)
Loop
' close the file
inFile.Close()
Else
MessageBox.Show("No savefile exists to display.")
End If
End Sub
End Class
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
Program using visual basic.net You will create a very simple two numbers calculator with save options;...
I need help with this problem in Visual Basic 2012: Write a program that allows the user to specify two numbers and then adds, subtracts, multiplies, or divides them when the user clicks on the appropriate button. The output should give the type of arithmetic performed and the result. Whenever one of the numbers in an input text box is changed, the output text box should be cleared. Also, if the number 0 is entered into the second text box,...
Project 2 – Memory Match Game Purpose This Windows Classic Desktop application plays a simple matching game. The game simulates a card game where the cards a placed face down and the player flips over pairs of cards in an attempt to find matching cards. Program Procedure Display a 4x4 grid of “face down” cards. Assign the letters A through H randomly to the cards in pairs. Allow the user to click on a card to “flip” it over and...
so im trying to make a grade program and idk what im doing wrong actually if someone can help? (heres the lines of code i have so far if its wrong let me know how to fix them Option Strict On Option Explicit On Public Class Form1 Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click Dim lblscore1 As Double Dim lblscore2 As Double Dim lblscore3 As Double lblscore1 = CDbl(Txtscore1.Text) lblscore2 = CDbl(Txtscore2.Text) lblscore3 = CDbl(Txtscore3.Text) lblaverage =...
WITH THIS CODE, ADD TO THE EXIT BUTTON THAT ALLOWS THE USER TO SEE UPON EXITING, HOW MANY QUESTIONS THEY GOT RIGHT AND WRONG. Public Class Form1 Dim r As Random = New Random Dim no1, no2 As Integer Private Sub rdbAdd_CheckedChanged(sender As Object, e As EventArgs) Handles rdbAdd.CheckedChanged txtAnswer.Clear() txtAnswer.BackColor = Color.White no1 = randomInt() no2 = randomInt() lblOperation.Text = "+" txtNumber1.Text = no1.ToString() txtNumber2.Text = no2.ToString() End Sub Public Function randomInt() As Integer Return r.Next(20, 120) End Function...
Project 10-1 Convert lengths In this assignment, you’ll add code to a form that converts the value the user enters based on the selected conversion type. The application should handle the following conversions: From To Conversion Miles - Kilometers: 1 mile = 1.6093 kilometers Kilometers - Miles: 1 kilometer = 0.6214 miles Feet - Meters: 1 foot = 0.3048 meters Meters - Feet: 1 meter = 3.2808 feet Inches - Centimeters: 1 inch = 2.54 centimeters Centimeters - Inches: 1...
C# Windows Form Application (CALCULATOR): (This is the instruction below): Windows Calculator that will going to create a Windows Form Application that will mimics a calculator. This is the screenshot how it shouldl look like. Calculator It should have a textbox and the following buttons: + Addition - Subtraction * Multiplication / Division = Equals (Will perform the final calculation) C Clear (Will clear the text box) There will be no maximize or minimize buttons. The rules are these: 2...
I am new to programming (2 weeks of playing with it) I have written code for a timer in Visual Studio 2013. I am wondering if someone can show me how to write code/what the code would look like in a MODULE1.vb. I was thinking that for this timer I could create MsgBox using a DO UNTIL LOOP that would pop up every 20 seconds that says "hurry up!" until 1 minute has passed. As I said I am just...
Assume you have a form containing a listbox, lstDogs. Write code for the button handler that will use an Input Box to ask the user to enter a dog breed such as Cocker Spaniel, Collie, etc. The program should keep asking for dogs until the user hits the Enter key with no input or clicks the "Cancel" button. (This is easier than you might think). Private Sub btnRun_Click(sender As Object, e As EventArgs) Handles btnRun.Click <========= your code goes here...
Public Class Form1 Private Sub CompleteReport_Click(sender As Object, e As EventArgs) Handles CompleteReport.Click Dim room As Double 'Assigns room as double Dim rate As Double 'Assigns rate as double Dim room2 As Double 'Assigns room as double Dim overallRate As Double 'Assigns overall as double Dim a As Integer 'Assign a as an integer For a = 1 To 8 'Assign a as an 1 to 8 for all 8 floors With...
C# Temp. Converter program. Create a Celsius and Fahrenheit Temperature Converter application. The application must have 2 Labels (each one of them assigned only to Celsius and Fahrenheit), 2 TextBoxes (each one of them assigned only to Celsius and Fahrenheit), only 1 Convert Button, 1 Clear Button, and 1 Exit Button. Also, 1 Error message label which will display the error messages. The application should only allow the user to enter the desired temperature just in one of the TextBoxes...