i need help please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nada
    New Member
    • Nov 2006
    • 1

    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
  • darklynx489
    New Member
    • Nov 2006
    • 2

    #2
    Originally posted by nada
    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 >.<

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by darklynx489
      Hi there Nada.
      ...
      Hope it's not too late now. I'll take the code already posted and modify it for factorial...
      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
      
      augmentor = 1
      for i = 2 to inputnumber
        augmentor = augmentor * i
      next i

      Comment

      Working...