Write a VBA code for a subroutine named diŽcheck that checks the sign of
the difference of two given numbers. The code should have the following structure:
When run the program should start by opening an InputBox with prompt \Enter
here a real number:" and title \First number". Once a number has been entered on
this InputBox another InputBox should open with prompt \Enter here another real
number:" and title \Second number".
After the two InputBoxes an IF structure should start which would do the following:
{ If the diŽerence of the numbers entered before is negative a MsgBox should
appear with prompt \the diŽerence is negative", title \diŽerence sign-check"
and a single OK button. The value of the difference should then be displayed
in cell C1 of the Excel Worksheet.
{ If the difference of the numbers is zero a MsgBox should appear with prompt
\the difference vanishes", title \difference sign-check", a single OK button and
a Critical Message Icon. The value of the difference should then be displayed
in cell C1 of the Excel Worksheet.
{ If the difference of the numbers is positive a MsgBox should appear with prompt
\the difference is positive", title \difference sign-check", a single OK button and
an Information Message Icon. The value of the difference should then be
displayed in cell C1 of the Excel Worksheet.
{ Finally, if any of the values entered is not a number, the program should open
a MsgBox with prompt \this is not a number", title \difference sign-check",
a single OK button and a Warning Query Icon. In this case, a GOTO
structure, should make the program start again from the beginning.
˛ Assign variables to all prompts and titles so that, for example, you only have to type
\difference sign-check" once.
Bookmarks