github VBAndCs/sVB-Small-Visual-Basic v2.6
Small Visual Basic v2.6.9

latest releases: v2.8, v2.7
18 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.6:

Write and run unit tests in sVB v2.6!
sVB makes it easy to write unit tests. Every form can define test functions among its normal function, and you can run them all easily just by calling the Form.RunTests() function, which will run the tests, and display the results on the form on a textbox named "txtTest". If the form doesn't contain a text with this name, it will be added in runtime, and this will not affect your form design when you run your app normally (not in test mode).
The test function must follow these rules, to be recognized by the RunTests method:

  1. Its name must start with Test_, like Test_FindNames.
  2. It must be a function not a sub, and it can't have any parameters.
  3. The function return value should be a string containing the test result like "passed" or "failed". It is better to mention the test name in the result.

The UnitTest Library:

To make things more easier, sVB samples folder contains the UnitTest project, which is used to create the UnitTest Library that is included in the sVB\Bin\Lib folder, so you can use it in your projects.
The library has these important methods:

  1. UnitTest.AssertEqual:
    Use this method to perform your tests. It receives three arguments:
  • The actual value that you got from executing the
    code being tested.
  • The expected value, that is the correct value that you should get when executing the code being tested.
  • The name of the test to include in the result.
    The AssertEqual method compares the actual value to the expected value And this method returns a string message, saying what is the result of the test:
  • If the two values are equal, it returns the message: "[Test Name] Passed".
  • If the two values are equal, this indicates that the test has failed, so, this methods returns the message: "[Test Name] Failed", and appends the actual and expected values to the message, so you can see what went wrong.
    Note that the both actual and expected values can be two single values, or two arrays. Using array of values allows you to do many small tests in the same test function. You should only do this if all these small tests are related and do the same test but with different values to cover all possible situations.

For an example on how to use this method, see the tests written in the UnitTest Sample app in the samples folder.

  1. UnitTest.RunAllTests:
    This method runs all the tests in all forms of the project. It has only one parameter, that receives the textbox you want to use to show the test results. This allows you to add a test form to your project, add a textbox on it, then add this line at the global section of the form code:
UnitTest.RunAllTests(TextBox1)

Now when you select the test form and run the project, all the tests in all forms of the project will be run, and you will see the error report (if any) in the textbox, so you can fix any errors.
Then, when you want to run your app normally, just select the main form and run the project!
By this simple way, you can switch easily between test mode and normal mode!
For an example on how to use this method, see the tests written in the UnitTest Sample app in the samples folder.

  1. UnitTest.RunFormTests:
    This method is just an alias to the Form.RunTests method. It is better to keep all unit test method together.
    The RunFormTests has one parameter that receives the name of the form you want to test. This makes it capable of running the form tests from another form or from the global module.

Note that I kept the UnitTest lib out of the Small Visual Basic Library, so you can modify its sVB source code, in case you want to add more Assert methods, or want to change the format of the result message.
So, have fun writing test for your code. Unit tests makes it easy to discover hidden errors, and you should run them each time you make changes to your code, as such changes can break some functionality of you app, so running the tests can make sure that every thing is working as expected, or there are some issues that needs to be fixed, which of course are related to the latest changes you have made.
This is why I am using the UnitTest lib right now to write a test project for Small Visual Basic Library, which discovers some small hidden bugs in the sVB library and the compiler, and I fixed them in this version.
In fact, what made me walk this path, is that I was adding example code snippets to the sVB reference book (still in progress), when I realized these snippets can be reused to test the sVB library, hence I crated the UnitTest Library and the sVB Tests project (still in progress too).

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

NewReleases is sending notifications on new releases.