Sample Problem on For Loop using VB 6.
Provide the expected output for the given program codes.
PROGRAM CODES
EXPECTED OUPUT
Private Sub Form_Activate()
Dim num As Integer
For num = 1 To 5
num=num+1
Print num
Next num
End Sub
Private Sub Form_Activate()
Dim num As Integer
For num = 1 To 5 Step 2
Print num
Next num
End Sub
Private Sub Form_Activate()
Dim num As Integer
For num = 1 To 5
num = num + 1
Label1.Caption = Label1.Caption & num
Next num
End Sub
Private Sub Form_Activate()
Dim s As String
Dim num1 As Integer
Dim num2 As Integer
For num1 = 1 To 5 Step 2
Label1.Caption = Label1.Caption & vbNewLine
For num2 = 1 To num1
s = str(num2)
s = "#"
Label1.Caption = Label1.Caption & s
Next num2
Next num1
End Sub
Private Sub Form_Activate()
Dim s As String
Dim num1 As Integer
Dim num2 As Integer
For num1 = 10 To 1 Step -3
Label1.Caption = Label1.Caption & vbNewLine
For num2 = 1 To num1
s = str(num2)
s = "#"
Label1.Caption = Label1.Caption & s
Next num2
Next num1
End Sub
Page 1|1
1st Semester SY 15-16
GOOD LUCK AND GOD BLESS!!
-MS. B. TAG