Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

VB.Net, Calculator project that has 2 Text Boxes for number entry, a drop down list, OperatorList, for math operator, and a Calculate button. I need

VB.Net, Calculator project that has 2 Text Boxes for number entry, a drop down list, "OperatorList", for math operator, and a Calculate button.

I need to display a message on the "Result Label", not a message box, stating "You cannot divide by zero". My code is below but the message won't display. Please help.

Protected Sub CalculateButton_Click(sender As Object, e As EventArgs) Handles CalculateButton.Click If ValueBox1.Text.Length > 0 AndAlso ValueBox2.Text.Length > 0 Then

Dim result As Double = 0 Dim value1 As Double = Convert.ToDouble(ValueBox1.Text) Dim value2 As Double = Convert.ToDouble(ValueBox2.Text)

Select Case OperatorList.SelectedValue Case "+" result = value1 + value2 Case "-" result = value1 - value2 Case "*" result = value1 * value2 Case "/" result = value1 / value2 End Select If OperatorList.SelectedValue = "/" Then If value2 <> 0 Then ResultLable.Text = "You cannot divide by Zero" Else result = value1 / value2 End If End If ResultLable.Text = result.ToString() Else ResultLable.Text = String.Empty End If End Sub

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago