Ask 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 = p*i

Next i

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

End sub

+4
Answers (1)
  1. 12 May, 06:21
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers