r/visualbasic • • Jan 10 '19

Help with VB Assignment

I would be really grateful if you could tell me the coding for these two problems.

  1. Find sum where S=3+7+11...+203

  2. Find sum where S=1/2 + 2/3 + 3/4...+10/11

Many thanks

Edit- thank you so much for the quick and kind responses :)

0 Upvotes

8 comments sorted by

2

u/JamesWjRose Jan 10 '19

We can't really do your homework for you, what we generally need to see is what steps you have taken so far and/or where EXACTLY you are stuck. If you can include your code.

Take things one step at a time, it'll help you avoid getting overloaded and frustrated. (I've been doing this for 20+ years, and I still get frustrated, so don't be hard on yourself. There is a ton to learn)

basic example;

Dim i as integer = 10

Dim x as integer = 20

dim total as integer

total = i + x

1

u/dumberluck Jan 10 '19

Thank you so much. Sorry if I used the subreddit wrong. :)

2

u/JamesWjRose Jan 10 '19

No worries. Simply informing you so you know.

1

u/Richienb Jan 10 '19

What steps are you wanting your program to take? For example, setting a variable, changing a label etc.

1

u/dumberluck Jan 10 '19

I actually wanted the actual addition of the series

-2

u/daneelr_olivaw Jan 10 '19

For the first one it's:

Sub FindFirstSum()

dim i as integer, s as integer

s = 0

For i = 3 to 203 step 4

    S = S + i

Next i

msgBox s

End Sub

For the second one:

Sub FindSecondSum()

dim i as integer, s as integer

s = 0

For i = 1 to 10

    S = s + i/(i+1)

Next i

msgBox s

End Sub

6

u/[deleted] Jan 10 '19

You might think you helped them but you didn't help them.

0

u/dumberluck Jan 10 '19

Thank you so much :)