467,151 Members | 929 Online

 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 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 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 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   augmentor = 1 for i = 2 to inputnumber   augmentor = augmentor * i next i Nov 9 '06 #3