what are the number of loops?

sarahaf04 41 Reputation points
2022-03-29T23:33:14.02+00:00

For intA = -2 To 13 Step 3

For intB = 4 To -5 Step -2

For intC = 10 To 20 Step -5

For intD = 0 To 10

For intE = 20 To 120 Step 10

Developer technologies | VB
{count} votes

2 answers

Sort by: Most helpful
  1. MotoX80 37,151 Reputation points
    2022-03-30T00:09:05.85+00:00

    Is this a trivia question? A homework question?

            Dim count As Integer = 0
            For intA = -2 To 13 Step 3
                count = count + 1
            Next
    
            For intB = 4 To -5 Step -2
                count = count + 1
            Next
    
            For intC = 10 To 20 Step -5
                count = count + 1
            Next
    
            For intD = 0 To 10
                count = count + 1
            Next
    
            For intE = 20 To 120 Step 10
                count = count + 1
            Next
            MsgBox(count)
    
    0 comments No comments

  2. Jiachen Li-MSFT 34,231 Reputation points Microsoft External Staff
    2022-03-31T09:08:38.607+00:00

    Hi @sarahaf04 ,
    You can use the following code to check each number of the loops.

            Dim count As Integer = 0  
            For intA = -2 To 13 Step 3  
                count = count + 1  
            Next  
            Console.WriteLine(count)  
    

    And the answer is 6,5,0,11,11.
    Best Regards.
    Jiachen Li

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.