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

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,400 questions
{count} votes

2 answers

Sort by: Most helpful
  1. MotoX80 29,286 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 21,871 Reputation points Microsoft Vendor
    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