0% found this document useful (0 votes)
26 views1 page

VBA and BASIC Code Snippets

This document contains code snippets in VBA and BASIC programming languages. The VBA code has a subroutine that contains a Do loop with an IF condition to exit the loop if x equals 2. It also has a message box to confirm continuing. The BASIC code calculates the factorial of a user-input number. It checks if the number is positive, and displays either the factorial result or an error message depending on the number.

Uploaded by

khrid3
Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
26 views1 page

VBA and BASIC Code Snippets

This document contains code snippets in VBA and BASIC programming languages. The VBA code has a subroutine that contains a Do loop with an IF condition to exit the loop if x equals 2. It also has a message box to confirm continuing. The BASIC code calculates the factorial of a user-input number. It checks if the number is positive, and displays either the factorial result or an error message depending on the number.

Uploaded by

khrid3
Copyright
© © All Rights Reserved
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

Next i

Range("E4").Value = x
End If
Response = MsgBox("Continue?", vbYesNo)
If Response = vbNo Then
Exit Sub
End If
Loop
End Sub

VBA CODE for Problem 1.5


Sub MacPro01()
Do
Block 1
IF x = 2 THEN EXIT
Loop
End Sub
REM

*****

BASIC

*****

Sub Main
Dim x as double, y as double, i as integer, factorial as double
x=InputBox("Please Enter a number")
if x>=0 then
if x=0 then
y=1
MsgBox(1)
else
factorial = 1
For i = 1 to x
factorial = factorial * i
Next i
MsgBox(Factorial)
end if
else
Msgbox ("Error!!! Factorial of negative number doesn't exist.")
End if
End Sub

You might also like