By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,594 Members | 2,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,594 IT Pros & Developers. It's quick & easy.

i need help please

P: 1
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
Share this Question
Share on Google+
2 Replies


P: 2
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 5K+
P: 8,434
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.