VBA - gregorymorrison/euler1 GitHub Wiki

I have to be honest - I've never understood why VBA has such a bad rap. Other programmers seem to loathe this language that was introduced in 1983, but I just view it as a tool - one that lets me get work done. It doesn't get in my way; it honestly took me around two minutes to write this version of Euler1 after having not used the language in a few years.

Function euler1(x)
    euler1 = 0

    For i = 1 To x - 1
        If i Mod 3 = 0 Or i Mod 5 = 0 Then
            euler1 = euler1 + i
        End If
    Next
End Function

Sub main()
    MsgBox (euler1(1000))
End Sub

Now, Linux doesn't have an implementation of VBA (that I know of), and I don't have an installation of Visual Basic anymore. However, Excel has a somewhat hidden instance of VBA. If you want to try this from Excel - bring up the VBA IDE using Alt-F11. From there, right-click on VBAProject, and Insert a Module which you can code in. To execute, click the arrow in the toolbar.