github VBAndCs/sVB-Small-Visual-Basic v2.5
Small Visual Basic v2.5.5

latest releases: v2.8, v2.7, v2.6...
20 months ago

Instructions:

  • Expand the Assets list at the bottom of the page and download the ZIP file.
  • Unzip the sVB.zip file. You will have a folder with the same name where you unzipped the file. Open the folder and double-click sVB.exe.
  • sVB needs .NET framework 4.8. If you don't have it on your PC, download and install it:
    https://go.microsoft.com/fwlink/?LinkId=2085155
  • The samples folder in sVB folder contains many samples that covers the language features.
  • Click the Form code tab at the top of the window to switch to the sb code editor.
    Note that you can right-click any .sb file and chose open with from the context menu, then choose sVB.exe as the default program to open .sb files. After that you can just double-click any .sb file to open it in sVB.
  • For more info about sVB syntax see the ReadMe file

What's new in sVB v2.5:
sVB is ready to create productive desktop apps.

  1. The toolbox now contains four new controls:
  • ProgressBar, ScrollBar and Slider: These bars are horizontal only, but you can use the rotate thumb of the control on the designer to rotate them to become vertical! For more info, see the Progress and Slider Color Composer apps in the samples folder.
  • ToggleButton: This control can be checked or unchecked but it seems like a button that appears clicked or un-clicked. See the Toggle Buttons app in the samples folder.
  1. You can add many timers to the form, by calling the Form.AddTimer Method. Small Basic library already contains the Timer object, but it is only one timer, and it makes code harder to make it handle different actions in different intervals. Besides, it may not work properly with forms and controls, and of course it will be missy if you try to use this single timer to handle different actions in many forms. So, to make things easier, you can now add as many timers as you need to each form!
    For example, the Stop Watch app in the samples folder uses two timers, one to update the current date and time displayed on the form title bar, and the other one to count the elapsed time for the stop watch.

  2. You can show the open file and save file dialogs to the user by calling File.OpenFileDialog and File.SaveFileDialog methods. You must send the extensions filter to these methods, which controls the types of files that the browser will show to the user. You can use the standard .NET filter string like "Text Files|*.txt;*.rtf|Docs|*.doc", or you can send the filter as an array like

fileName = File.OpenFileDialog ({
   {"Text Files", "txt", "rtf"},
   {"Docs", "doc"}
})

For an example, see how these methods are used to open and save files in the sVB notepad app in the samples folder.

  1. You can show the font dialog to let the user choose font properties, by calling the Desktop.ShowFontDialog method. This method empty string "" if the user canceled the operation, otherwise it returns an array containing the font properties under the keys Name, Size, Bold, Italic, Underlined and Color, so you can use these keys as dynamic properties:
Font = Desktop.ShowFontDialog(Me.Font)
Me.FontName = Font!Name
Me.FontSize = Font!Size

In the above example, you see that the ShowFontDialog has a parameter that receives an array containing the initial font properties. To make this easy, each control now has a Font property that returns an array with the font properties. You can also use this property to change font properties of the control in one step:

font = Desktop.ShowFontDialog(Me.Font)
If font <>"" Then
   Me.Font = font
EndIf

And to make this even easier, each control has a ChooseFont methods that shows the font dialog and sets its result to the controls Font property, so the above 4 lines can be replaced with this single line (or in fact these two words!):

Me.ChooseFont()
  1. If you want to crate a custom font dialog, you will need to know the font names defined on the user's system. In such case, use the Desktop.FontNames property to get an array containing these font names.
    For a sample on how to create a custom font dialog, see the FrmOps in the sVB notepad app in the samples folder.

  2. You can show the color dialog to allow the user to choose a color, by calling the Color.ShowDialog method. And for simplicity, each control has the ChooseForeColor and ChooseBackColor methods to show the dialog and change the control fore and back colors directly.

  3. You can now crate a main menu for the form by using the Form.AddMainMenu method, that returns the main menu object, which you can use it's AddItem method to add menu items.
    For more info, see how the menus are defined in the formMain in the sVB notepad in the samples folder.

  4. You can show a child form that it owened by a parent form by calling the Form.ShowChildForm method.
    A child form will alowys appear on top of its parent form even when you activate the parent form. If you hide or minimize the parent form, its child will be hideen with it, and when you show the parent form again, its child will appear again.
    For example, this is how the FormMain shows the frmFind as a child form in the sVB notepad in the samples folder"

Me.ShowChildForm("FrmFind", TxtEditor)

Ther first argument is the name of the child form (and the auto completion list will offer the names of the forms for you), and the second param is an extra data that will be passed to the ArgsArr property in the child form.

  1. You can change the style of the form and controls by loading styles from a recource dictionary. This is an advanced topic, that needs knowlage about XAML and WPF, but it always you to make use of syles and thems defiend for WPF, UWP or WinUI3 to make a beautiful design, and change how controls look and even work!
    All you need is to have a Resource dictonary in a Xaml file, then use these two methods to load it:
  • Control.SetRecourceDictionary: send the xaml file path to this method to load stryles from it into the control and its child controls. This means that if you called it from a form. the styles will affect all target controls if exists on it. Note that this method needs that styles have no keys. Styles with names (keys) will not be aplied to controls here.
  • Control. SetStyle: it is similal to the previous method, but it has a second parameter that recives the name (key) of the style. It is useful when you want to apply a style on only one control.
    Note that if the style have no name, you can call SetRecourceDictionary from this control instead to apply the style on it, but this can also apply another styles on the controls if the resource dictionary has many styles targetting the same control type.
    For mor info, see the Custom Styles app in the samples folder. the tow files RoundCorner.style and RoundCorner2.style are in fact XAML files, but I changed there extensions from .xaml to .style not to be cinfused with form design files. But if you used .xaml extension it will also work.
  1. If you want something easier, you can change the Button and ToggleButton appearenace by setting the Flat property to True. This will help you use theem as a toolbar buttons by butting a label under them, as you can see in the Toggle Buttons app in the samples folder.

  2. Use Form.Icon property to set the icon that appears on the form title bar.

  3. Use the Program.SaveSettings method to save a value to the windows registry, and use the Program.GetSettings method to read this value back from the registry.

Create an external library for sVB:

sVB can use external libraries created for Small Basic (like LitDev). Just insert those libraries dll files in the sVB\Bin\Lib folder and you are ready to go!
This means you can also write such libraries (using C# or VB.NET), to add new functionality that is not available in sVB. To do this, you should follow these rules:
https://social.technet.microsoft.com/wiki/contents/articles/53826.small-basic-extensions.aspx
The above rules will allow you to create a library for Small Basic, which also will work with sVB. But you can create a library for sVB only, by targeting .NET Framework 4.8 and referencing the SmallVisualBasicLibrary.dll file (found in sVB\bin folder) instead of SmallBasicLibrary.dll, and you can mark your functions and properties with the ReturnValueTypeAttribute to specify the return value type, to allow sVB to infer the type of expressions that use these functions and properties. For example:

<ReturnValueType(VariableType.Double)>
Public Shared Function Sum(x As Primitive, y As primitive) As Primitive
Return x + y
End Function

For more info, see the DemoLib project at the samples folder. It is a VB.NET project that crates a DemoLib.dll in its bin\release folder, which I copied to the sVB\bin\lib folder so you can try it with DemoLibSample app in the samples folder.

Now we can announce sVB as a mature productive dssktop programming language, and you can use it to build interesting apps. Have fun.

Don't miss a new sVB-Small-Visual-Basic release

NewReleases is sending notifications on new releases.