Question: Write a program to help small towns estimate the length of parades, like their July 4th parade. Parades have floats and marching bands. Each float
Write a program to help small towns estimate the length of parades, like their July 4th parade.
Parades have floats and marching bands. Each float needs 30 meters. Each band needs 100 meters.
The worksheet starts like this:

The user types the number of floats and bands, and presses Run.
Add validation. Make sure that floats and bands are numbers, and zero or more. If the data is bad, show an error message in a MsgBox, and end the program. For example:

If the input is OK, compute and output the result.

Follow the usual coding standards for indenting and such. Below is my current code, it doesn't seem to do the job properly...
Option Explicit Private Sub cmdRun_Click()
'determine if the input is valid
If Not IsNumeric(Cells(1, 2).Value) Then MsgBox ("Sorry, floats must be a number") End If If Not IsNumeric(Cells(2, 2).Value) Then MsgBox ("Sorry, Bands must be a number")
End If
'declare variables Dim a As Integer Dim b As Integer Dim length As Integer 'set the values into variable a = Cells(1, 2).Value b = Cells(2, 2).Value 'calculate the length of parades length = a * 30 + b * 100 Range("B6").Value = length
End Sub
1 Floats: 2 Bands: 0 Run meters 6 Length
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
