CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 1999
    Location
    Baytown, TX, United States
    Posts
    23

    Please help! Need For Next loop for square!

    I need a For Next loop that will calculate and display the square of the even numbers from 2 to 12.

    kazooie21

  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Please help! Need For Next loop for square!


    Dim i as Integer
    for i = 2 to 12
    If i Mod 2 = 0 then
    Debug.print i & " " & Sqr(i)
    End If
    next i





  3. #3
    Join Date
    Oct 1999
    Location
    CA
    Posts
    91

    Re: Please help! Need For Next loop for square!

    Since Mod is a relatively slow process I would use the step option instead of mod'ing each iteration.


    Dim i as Integer

    for i = 2 to 12 step 2
    Debug.print i & " " & Sqr(i)
    next i




    Brewguru99

  4. #4
    Join Date
    May 1999
    Posts
    3,332

    Re: Please help! Need For Next loop for square!

    although I doubt that speed is a major concern in this case :-)
    , I think you solution is more elegant.


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