Ask Question
23 October, 05:35

Must i but End if in this visual basic. 6 program

Sub main ()

Dim i as integer, p as integer

P = 1

For i = 1 to 100

if (1 mod 4 = 0) then

p = p*i

Next i

MsgBox " الناتج هو " & p

End sub

+5
Answers (1)
  1. 23 October, 08:43
    0
    You use end if only if the entire statement does not fit on one line.

    So this format does not require end if:

    If condition Then [ statements ]

    And this one does:

    If condition [ Then ]

    [ statements ]

    End If

    I left out the else syntax for simplicity.

    So the example program you gave will require an end if before the next i.

    The expression in the if statement should be (i mod 4) rather than (1 mod 4). Typo?
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Must i but End if in this visual basic. 6 program Sub main () Dim i as integer, p as integer P = 1 For i = 1 to 100 if (1 mod 4 = 0) then p ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers