CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Visual Basic

  1. #1
    Join Date
    Oct 2010
    Posts
    2

    Visual Basic

    1. Modify the summation procedure in lesson in action and use Do-Until loop instead.
    2. How many times does the following loop iterates?

    intX = 20
    Do While (intX > = 1)
    intX = intX + 1
    Loop

    3. Create a program that asks for a number and computers for its factorial. The Factorial of 3 is 6 (1 x 2 x 3).Factorial of 5 is 120 (1 x 2 x 3 x 4 x 5). You may use the same Form and change the caption of the button from summation to Factorial. Also, make sure that the user enters a number using the IsNumeric () Function.Display appropriate messages in the label if the user enters non-numeric values.

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Visual Basic

    Looks like homework.
    You need to do this yourself.
    If you are stuck show what you have done and where you have a problem and you will get some help.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Sep 2010
    Location
    Russia
    Posts
    15

    Talking Re: Visual Basic

    Quote Originally Posted by azzaq View Post
    2. How many times does the following loop iterates?

    intX = 20
    Do While (intX > = 1)
    intX = intX + 1
    Loop

    Are U crazy? It will iterate while intX>=1. Pizdets!

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Visual Basic

    Well, what do you set it as BEFORE the first line? How is it supposed to know where to STOP? Might you want to SUBTRACT instead?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Visual Basic

    Well, the serious answer is: the loop iterates 32747 times and then the program crashes with an overflow error That is because intX will then try to increment from 32767 to 32768 which is not allowed. (assumed intX was declared As Integer).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured