Search code examples
visual-studiovisual-studio-2012smallbasic

Small Basic - When would 'Graduate' be used?


So today I decided to take a look at the Graduate feature in small basic, I discovered that it allows you to convert your small basic code to a format for Visual Studio, Great I thought.

Until when I later tried it, Visual Studio reported that there were over 102 errors with the code, I found that this was because the compiler couldn't understand most of the small basic functions like GraphicsWindow, TextWindow, Mouse, Shapes etc. So, have I done wrong? As Visual Studio is my main programming language I couldn’t wait for the small basic code to be magically converted to work with VS. Some of the code could be manually translated such like TextWindow to Console, but what do you do with code that is specific to Small Basic like GraphicsWindow?


Solution

  • You are using the Graduate feature correctly, and you haven't done anything wrong; the reason you're getting errors is because Visual Studio doesn't seem to automatically import SmallBasicLibrary.dll correctly. The last time I used Graduate (~2 years ago) this wasn't a problem, so I imagine this issue is a result of Visual Studio updates.

    Thankfully, this issue is easy to fix. You simply need to import SmallBasicLibrary.dll manually and then add a single line to the top of your Visual Basic code. Note that these instructions are for Visual Studio Community 2013, but I would imagine they're the same for most recent versions.

    1. In Visual Studio, go to Project > [Project Name] Properties.

    Screenshot

    1. In the tab that opens, go to References on the side panel. Select SmallBasicLibrary in the list and click Remove.

    Screenshot

    1. Click the Add button (next to Remove), then in the window that opens select Browse in the side panel. Now click the Browse button at the bottom of the window.

    Screenshot

    1. Find SmallBasicLibrary.dll in your Small Basic installation folder (for me this was C:\Program Files (x86)\Microsoft\Small Basic) and double-click it. When you are taken back to the Reference Manager window, ensure that SmallBasicLibrary.dll has its checkbox checked, then click OK.

    Screenshot

    1. Select Application in the side panel and ensure that the targeted version of the .NET framework is 4.5.

    Screenshot

    Finally, open your Visual Basic code using the Solution Explorer and add this line to the top of it:

    Imports Microsoft.SmallBasic.Library
    

    The resulting code should look something like the following:

    Imports Microsoft.SmallBasic.Library
    
    Module UntitledModule
        Sub Main()
            TextWindow.WriteLine("Test")
            TextWindow.Pause()
            ' Your Small Basic code here...
        End Sub
    End Module
    

    All your build errors should be gone, as the Small Basic commands are now available.

    Once you've done this, Graduate is ideal for using VB-exclusive commands or libraries along with your Small Basic code.