Provide The Expected Output For The Given Program Codes. Program Codes Expected Ouput
The document provides sample VB code using for loops and their expected outputs. There are 5 code samples that use for loops to print numbers, increment a variable, or add to a label caption. The code demonstrates basic for loop syntax and usage to iterate from 1 to 5, with some using a step value or nested loops. The expected output is provided for each code sample to test for loop behavior.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
34 views1 page
Provide The Expected Output For The Given Program Codes. Program Codes Expected Ouput
The document provides sample VB code using for loops and their expected outputs. There are 5 code samples that use for loops to print numbers, increment a variable, or add to a label caption. The code demonstrates basic for loop syntax and usage to iterate from 1 to 5, with some using a step value or nested loops. The expected output is provided for each code sample to test for loop behavior.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
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