Question: In VB.NET I need to Create a new WEB SITE with the following:- Create a webpage that contains server side directives, code declaration blocks, includes

In VB.NET I need to Create a new WEB SITE with the following:-

  1. Create a webpage that contains server side directives, code declaration blocks, includes and controls.
  2. Create a simple calculator the contains four labels, three textboxes, six buttons and a list box:
  3. The first label = enter first number
  4. The second label= enter second number
  5. The third label = should display the result
  6. Four of the buttons should be "+", "-", "*", "/"
  7. The result textbox should be read only
  8. The startup page must be named index.
  9. Display a message indicating cannot divide by when the user click / and there is a zero the in the second box
  10. Prevent the user from entering text in the number fields
  11. Create the other two buttons
    1. store data - The store data will store the results into array
    2. display data - The display data will display the contents of the array (use 10 for the array size)

I need some help with steps 10 & 11 on the server side.

Heres what I have so far for the VB.NET website and code behind:

Index.aspx:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Index.aspx.vb" Inherits="Calculator.Index" %>

Welcome to the VB Calculator!



Index.aspx.vb:

Option Explicit On

Option Strict On

Option Infer Off

Public Class Index

Inherits System.Web.UI.Page

'Declares the variables

Dim dec1stNum As Decimal

Dim dec2ndNum As Decimal

Dim decResult As Decimal

Dim count As Integer = 0

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub

Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click

'Accepts input from txt1stNum & txt2ndNum

Decimal.TryParse(txt1stNum.Text, dec1stNum)

Decimal.TryParse(txt2ndNum.Text, dec2ndNum)

'Adds the 1st & 2nd numbers & displays the results

decResult = dec1stNum + dec2ndNum

txtResult.Text = dec1stNum & " + " & dec2ndNum & " = " & decResult

End Sub

Protected Sub btnSubtract_Click(sender As Object, e As EventArgs) Handles btnSubtract.Click

'Accepts input from txt1stNum & txt2ndNum

Decimal.TryParse(txt1stNum.Text, dec1stNum)

Decimal.TryParse(txt2ndNum.Text, dec2ndNum)

'Subtracts the 2nd number from the 1st number & displays the results

decResult = dec1stNum - dec2ndNum

txtResult.Text = dec1stNum & " - " & dec2ndNum & " = " & decResult

End Sub

Protected Sub btnMultiply_Click(sender As Object, e As EventArgs) Handles btnMultiply.Click

'Accepts input from txt1stNum & txt2ndNum

Decimal.TryParse(txt1stNum.Text, dec1stNum)

Decimal.TryParse(txt2ndNum.Text, dec2ndNum)

'Multiplies the 1st & 2nd numbers & displays the results

decResult = dec1stNum * dec2ndNum

txtResult.Text = dec1stNum & " X " & dec2ndNum & " = " & decResult

End Sub

Protected Sub btnDivide_Click(sender As Object, e As EventArgs) Handles btnDivide.Click

'Accepts input from txt1stNum & txt2ndNum

Decimal.TryParse(txt1stNum.Text, dec1stNum)

Decimal.TryParse(txt2ndNum.Text, dec2ndNum)

decResult = dec1stNum / dec2ndNum

'Displays a message box if the 2nd number entered is a 0

'If the 2nd number is not a 0, divides the 1st number by the 2nd number & displays the results

If dec2ndNum = 0 Then

MsgBox("cannot divide by 0")

txt2ndNum.Text = String.Empty

txt2ndNum.Focus()

Else

txtResult.Text = dec1stNum & " / " & dec2ndNum & " = " & decResult

End If

End Sub

Private Sub btnStoreData_Click(sender As System.Object, e As System.EventArgs) Handles btnStoreData.Click

Dim PrevOps(9) As String

Console.WriteLine(txtResult.Text)

Console.ReadKey()

End Sub

Private Sub btnDisplayData_Click(sender As System.Object, e As System.EventArgs) Handles btnDisplayData.Click

'Reads the Prevous Operations from the PrevOps text file and displays them in the list box

'Declares the variables

Dim inFile As IO.StreamReader

Dim strOperation As String

'Clears the previous PrevOps from the list box

lstPrevOps.Items.Clear()

'Determine wether the file exists

If IO.File.Exists("DisplayData.txt") Then

'Opens the file for input if it exists

inFile = IO.File.OpenText("DisplayData.txt")

'Processes the loop instructions until the end of the file

Do Until inFile.Peek = -1

'Reads the operation

strOperation = inFile.ReadLine

'Adds the operation to the list box

lstPrevOps.Items.Add(strOperation)

Loop

'Closes the file

inFile.Close()

End If

End Sub

End Class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!