Small Basic - How to Create an Extension Using VB.NET
Published Feb 12 2019 02:32 PM 484 Views
Microsoft
First published on MSDN on Aug 20, 2013

Authored by Ed Price


It's time for another guest blogger! This one is from Noah Buscher.


Find the latest version of this article on TechNet Wiki: Small Basic: How to Create an Extension Using VB.NET



This article is about how to create a simple extension that you can build on for Small Basic (Microsoft). To get started you will need Small Basic, .NET Framework 3.5, and Visual Basic.NET 10. If you wish to see a tutorial for writing an extension in C#, click here .


STEP 1: Create an Extension



  1. Open Visual Basic and click on "Create New Project"

  2. Click on "Class Library" and name it "MyFirstExtension"

  3. After the project has loaded, delete all the code from Class1, and paste in the following code:



  4. Imports System

    Imports Microsoft.SmallBasic.Library

    Imports System.Threading

    Imports System.IO

    <SmallBasicType()> _

    Public Module FirstModule


    Public Function ShowMessage( ByVal MsgTxt As Primitive) As Primitive

    MsgBox(MsgTxt.ToString)

    End Function

    End Module



  5. Open the Solution Explorer and right-click on "MyFirstExtension" and go down to "Add Resource"

  6. After the dialog opens click on the "Browse" tab and go to your Small Basic folder and click on "SmallBasicLibrary.dll"

  7. That should take away all the errors



STEP 2: Make it Work



To allow the extension to work in Small Basic, we need to change the Target Framework to .NET 3.5.


  1. Click on the Save button at the top of the screen

  2. Go to Projects>MyFirstExtension Properties

  3. Click on the "Compile" tab

  4. Click on "Advanced Compile Options" at the bottom

  5. Click on the drop-down for "Target Framework" and select .NET 3.5

  6. Click "OK" and when the dialog pops up, click "Yes"

  7. You can reopen the extension by opening the Solution Explorer and double-clicking on "Class1.VB"

  8. Now, build the .dll by going to the top of the screen and clicking on Debug>Build MyFirstExtension

  9. This will build the .dll to the "bin>Release" folder in the project

  10. Go to the "bin>Release" file in File Explorer and copy all the files, except all the ones named "SmallBasicLibrary.dll" and "SmallBasicLibrary.xml"

  11. Open Small Basic's folder and create a "lib" folder if there is already not one there

  12. Open the "lib" folder and paste the programs inside YOU MAY NEED ADMIN PRIVILEGES TO DO THIS

  13. Close Small Basic if it is open and re-open it

  14. Now, all you have to do to use the extension is type in FirstModule.ShowMessage("YourMessageBoxTextHere")



STEP 3: Moving On



To create more functions in the FirstModule, all you have to do is add more functions. If you need to get any variables from the user, just separate the ByVal YOURVARIABLE with commas. If you need to return a function, just put return before it like:



Public Function NetOpen() As Primitive

Return My.Computer.Network.IsAvailable

End Function



If you would like a Small Basic Extension with tons of functions, just visit List of SmallBasic Extensions to get it! Remember, the Small Basic community is active, so feel free to ask questions. Good luck!

Other Languages



See Also


Version history
Last update:
‎Feb 12 2019 02:32 PM
Updated by: