Would MS introduce Small Visual Basic to kids?

Small Visual Basic 411 Reputation points
2022-09-15T22:15:54.3+00:00

I've built Small Visual Basic (sVB) on top of Small Basic, with many enhancements in syntax and code editor, in addition to an easy to use form designer and a small windows forms library.
sVB is still a dynamic language, but it offers good support for basic data types like String, Double, Date, Array and Color by inferring the variable type from its initial value.
sVB is semi object oriented, as it makes variables act like objects by accessing extension methods from Text, Math, Date, Array, Color and Control classes. All of this happens behind the scene to make the code shorter and easier for kids. The kid has only to drag a TextBox and a Button on the form, double click the button to switch to its click event handler, and write the code directly, such as:
TextBox1.Text = "Hello sVB!"
The source code of sVB is fully written in VB .NET:
https://github.com/VBAndCs/sVB-Small-Visual-Basic
So, can MS introduce this enhanced version to kids?
It is compatible with SB with a few breaking changes (esp variable domains), and it can be more attractive to nowadays kids, that kept asking me about opening new forms, dealing with dates, and using AI (the latter is still missing of course, and this is why kids are eager to learn Python, and thi sis why I am thinking of some support of ML.NET in sVB in the future!)

Small BASIC
Small BASIC
A programming language created by Microsoft that serves a stepping stone for beginners from block-based coding languages to more complex text-based languages.
277 questions
{count} votes

24 answers

Sort by: Most helpful
  1. Small Visual Basic 411 Reputation points
    2022-11-12T01:55:06.453+00:00

    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).


  2. Small Visual Basic 411 Reputation points
    2022-12-12T20:03:05.46+00:00

    What’s new in sVB 2.7:
    1- Fixing many small bugs while adding tests to the sVB Tests project.
    2- sVb gave some love to the graphics window, so now you can use the Controls.AddXX methods to add many controls on the graphics window, and use them in the same way you do when you add them on any other form. For example, you can add a ComboBox on the graphics window, add items to it and select the second item like this:

       Combo = Controls.AddComboBox(50, 50, 100, -1)  
       Combo.AddItem({10, 20, 30})  
       Combo.SelectedIndex = 2  
    

    you can also handle the ComboBox events like this:

       Combo.OnSelection = Combo_Selected  
    
       Sub Combo_Selected()  
          GraphicsWindow.ShowMessage(Combo.SelectedItem, Combo.SelectedIndex)  
       EndSub  
    

    For more info about the new available controls, try these methods:
    * Controls.AddCheckBox
    * Controls.AddComboBox
    * Controls.AddDatePiker
    * Controls.AddLabel
    * Controls.AddListBox
    * Controls.AddProgressBar
    * Controls.AddRadioButton
    * Controls.AddScrollBar
    * Controls.AddSlider
    * Controls.AddTimer
    * Controls.AddToggleButton


  3. Small Visual Basic 411 Reputation points
    2022-12-22T02:38:46.857+00:00

    I updated sVB to v2.7.1 to allow it to run this Small Basic program:
    JKFK825.000
    The corresponding sVB program is:
    WRKN762.000
    This code can't run in older sVB versions, for 2 reasons:

    1. sVB 2.7.1 added the Math.Hex method.
    2. sVB 2.7.1 initializers are now faster. The code sample initializes an array with 2643 items, each of them is a 2 item sub array. This may take hours in SB and sVB (and this is why the original sample uses LtDev to get the array). The reason behind this slowness in that every time a new item is added to the array, SB creates a new array and copies the old items to it before adding the new item! Repeating this for 2643 items increases the time exponentially, which makes it totally impractical.
      I fixed this by introducing the Array.AddNextItem method, which appends the given value directly to the given array without any need to copy all the items to a new array. There is one limitation in using this method, that the array must contain one item at least, which means you must add the first item by the Array.AddItem method or the indexer [] then add next items by the Array.AddNextItem method. But in most cases, you don't need to use these two methods directly, because sVB will do that for you when you use the array initializer {}. This is why the large initializer in this sample will work in sVB 2.7.1 but not in any previous version.

  4. Small Visual Basic 411 Reputation points
    2024-01-14T17:54:42.76+00:00

    It is the 3rd anniversary since I announced the first prove of concept of sVB, and now sVB reached its 2.8.9 version, which finally got a small properties window. Also, sVB got the string concatenation operator & Happy birth day sVB! Download teh sVB installer. User's image

    0 comments No comments