467,151 Members | 929 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,151 developers. It's quick & easy.

i need help please

hi all,

i need your help in solving these two questions about vb really i need the answer as soon as possible today

the first question:
how can i write a VB .Net application that adds even numbers 0, 2, 4, until the sum of these numbers is greater to or equal to a specific value to be given by the user?

the second question:
how can i Write a VB .NET application that calculates the factorial. The factorial is the product of all the positive integers from 1 to a given number, for example, 4 factorial, usually written 4!, is equal to 24 (1 2 3 4 = 24). The user will enter through a textbox the desired number and you as programmer will display the result in a message box. It should be noted that 0! is by default equal to 1?

please if some one have the answer please past them
Nov 7 '06 #1
  • viewed: 1304
Share:
2 Replies
hi all,

i need your help in solving these two questions about vb really i need the answer as soon as possible today

the first question:
how can i write a VB .Net application that adds even numbers 0, 2, 4, until the sum of these numbers is greater to or equal to a specific value to be given by the user?

the second question:
how can i Write a VB .NET application that calculates the factorial. The factorial is the product of all the positive integers from 1 to a given number, for example, 4 factorial, usually written 4!, is equal to 24 (1 2 3 4 = 24). The user will enter through a textbox the desired number and you as programmer will display the result in a message box. It should be noted that 0! is by default equal to 1?

please if some one have the answer please past them

Hi there Nada.
I'm not sure if the code for .NET is the same as regular VB, but here's the code:
first answer:
just use a loop with step 2 to add them.something like this
<code>
dim i as integer 'this is the counter for the loop
dim augmentor as integer ' something to append to
dim inputnumber as integer 'this will be equal to what the user puts in

inputnumber = inputbox("Type the max number:", "Max Number") 'gets the number from the user

for i = 0 to inputnumber STEP 2
augmentor = augmentor+i
next i
</code>

im not sure if there's a class for that, but hey! there's the vb code, maybe you can translate it XD

as for the second part, i have code for this but again it's in normal VB, sooooo maybe i could give it to you and you could translate it.
i'll provide it later, i need to get back to class, im in school right now >.<
Nov 7 '06 #2
Expert 8TB
Hi there Nada.
...
Hope it's not too late now. I'll take the code already posted and modify it for factorial...
Expand|Select|Wrap|Line Numbers
  1. dim i as integer 'this is the counter for the loop
  2. dim augmentor as integer ' something to append to
  3. dim inputnumber as integer 'this will be equal to what the user puts in
  4.  
  5. inputnumber = inputbox("Type the max number:", "Max Number") 'gets the number from the user
  6.  
  7. augmentor = 1
  8. for i = 2 to inputnumber
  9.   augmentor = augmentor * i
  10. next i
Nov 9 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by Nathan Pinno | last post: by
17 posts views Thread by Marcin Borkowski | last post: by
6 posts views Thread by mike | last post: by
3 posts views Thread by Bob.Henkel@hartfordlife.com | last post: by
8 posts views Thread by skumar434@gmail.com | last post: by
reply views Thread by U S Contractors Offering Service A Non-profit | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.