-
Notifications
You must be signed in to change notification settings - Fork 2
VB.NET
Gregory Morrison edited this page Feb 5, 2023
·
3 revisions
VB.NET was introduced in 2001 as a successor to Visual Basic. I had had no prior experience with anything .NET, and was expecting a bit of a learning curve, but it took me five minutes to write this version of Euler1 - it looks just like VB6 of yore:
' Euler1 in VB.NET
Imports System
Public Module modmain
Function Euler1 (size As Integer) As Integer
For i As Integer = 1 to size
If (i mod 3 = 0 or i mod 5 = 0) Then
Euler1 = Euler1 + i
End If
Next
End Function
Sub Main()
Console.WriteLine (Euler1(999))
End Sub
End Module
To compile this code, I simply used Yum to install mono-basic. Then, I compiled my code with vbnc. I couldn't find how to execute the resultant .exe, so I guessed and tried to execute it the same way I ran my C# code - with the mono runtime. Success!
$ vbnc euler1.vb
$ mono euler1.exe
233168
$
Return home