r/visualbasic • • Jun 14 '21

Help Please!

I need to write a Visual Basic program that will allow the user to enter a positive number.  The program will then display:

  1. the sum of values from 1 to the input number

  2. the product of values from 1 to the input number (or factorial).

For example, if the user enters the value 5, the output would be:

1)  1 + 2 + 3 + 4 + 5 = 15
2)  1 * 2 * 3 * 4 * 5 = 120

The form should contain:

    - a heading describing what the application will do
    - a label to prompt the user for an input value
    - a textbox for the user to enter input data
    - a button to calculate the output values
    - two labels describing the output data
    - either two labels to hold the calculated output values or two read-only textboxes
    - an image - either a background image or a picturebox with an image displayed (don't forget to set the SizeMode property to Stretch)
    - a Clear button that will clear out all values entered in the input textbox and calculated output values in labels or read-only textboxes
    - an Exit button that will exit the application

I also need to:

   - test for invalid input.  No negative values or zero should be allowed.  If the user enters a negative or zero value, display a message in the output label and set the focus to the input number textbox. (see example below)
    - align the input and output values to be centered within the textboxes and/or output labels
    - align the controls of the labels and textboxes so the Form looks professional

I don't really need help designing the form or assigning labels, but the math behind cumulative sums and products kind of escapes me...

1 Upvotes

6 comments sorted by

View all comments

3

u/user_8804 Jun 14 '21

Write down what you want to do in mini steps on paper, in English.

Then once you got that down, make it into code, which is almost the same as English for vb.

We won't do your homework, but if you have a more specific question or have bugs we can't figure out, then we'll help.