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-10-09T17:19:20.857+00:00

    sVB 2.0 is released. It can create a multi form project with a common Global.sb module where you can declare plobal variables and subroutines that can be used from any form in the project via the Global. prefix, such as Globla.MyFuncution(). I thinks sVB is now the smooth transitional stage between Small Basic and VB.NET!
    https://github.com/VBAndCs/sVB-Small-Visual-Basic/releases/tag/v2.0
    The Show Dialogs app in the samples folder shows a good example on using the global file with three forms. It crates the famous VB MsgBox and InputBox functions to show a message Box and an Input Box.


  2. Small Visual Basic 411 Reputation points
    2022-10-13T00:18:49.973+00:00

    sVB 2.2 supports creating custom complex shapes using the GeometricPath type.
    For example, you can draw a hex polygon shape, add it to the shapes, then rotate it by this code:

       vb  
       GraphicsWindow.BrushColor = Colors.AliceBlue  
       GraphicsWindow.PenColor = Colors.Red  
       GraphicsWindow.PenWidth = 3  
         
       ' Crate a figure to draw a new custom shape  
         
       GeometricPath.CreateFigure(100, 100)  
       GeometricPath.AddLineSegment(50, 150, True)  
       GeometricPath.AddLineSegment(100, 200, True)  
       GeometricPath.AddLineSegment(200, 200, False) ' using `False` hides the line  
       GeometricPath.AddLineSegment(250, 150, True)  
       GeometricPath.AddLineSegment(200, 100, True)  
       GeometricPath.AddLineSegment(100, 100, True)  
         
       Sh1 = Shapes.AddGeometricPath()  
       Shapes.Rotate(Sh1, 45)  
    

    And you may use curves and arcs not just lines:

       vb  
       GraphicsWindow.BrushColor = Colors.Transparent  
       GraphicsWindow.PenColor = Colors.Blue  
       GraphicsWindow.PenWidth = 5  
         
       ' Create a new empty geometric path  
       GeometricPath.CreatePath()  
       GeometricPath.CreateFigure(100, 100)  
       GeometricPath.AddLineSegment(50, 150, True)  
       GeometricPath.AddArcSegment(100, 200, 20, 30, 30, False, True, True)  
       GeometricPath.AddLineSegment(200, 200, True)  
       GeometricPath.AddBezierSegment(210, 210, 230, 230, 250, 150, True)  
       GeometricPath.AddQuadraticBezierSegment(230, 110, 200, 100, True)  
       GeometricPath.AddLineSegment(100, 100, True)  
       Sh2 = Shapes.AddGeometricPath()  
       Shapes.Move(Sh2, 130, 100)  
    

    You can also combine some basic shapes in one path:

       vb  
       GraphicsWindow.BrushColor = Colors.Yellow  
       GraphicsWindow.PenColor = Colors.Black  
       GraphicsWindow.PenWidth = 1  
         
       GeometricPath.CreatePath()  
       GeometricPath.AddLine(100, 100, 400, 400)  
       GeometricPath.AddRectangle(100, 100, 200, 200)  
       GeometricPath.AddEllipse(150, 150, 100, 100)  
       GeometricPath.AddTriangle(300, 300, 400, 200, 400, 400)  
       Sh3 = Shapes.AddGeometricPath()  
       Shapes.Move(Sh3, 300, 0)  
       Shapes.Rotate(Sh3, 45)  
    

    You can see this code in action in the Geometric Path app in the samples folder. And this is the 3 shapes that the above code draws:
    image


  3. Small Visual Basic 411 Reputation points
    2022-10-14T16:05:35.167+00:00

    (sVB v2.3)[https://github.com/VBAndCs/sVB-Small-Visual-Basic/releases/tag/v2.3] can create a code library!
    For the first time, it is now possible to use an sVB app as a library! Follow these instructions:

    1. Create a sVB project with a global file. Choose a suitable name for the folder that you save the project files to (such as MyLib), because the name of this folder will be the name of your library. Don't use spaces nor symbols.
    2. Add variables, subroutines, and functions to the global files. These are the members that you can access from the lib.
    3. Add comments for each variable, subroutine, parameter, and return value. These comments will be saved as the documentation for your lib, and will be shown in popup help in sVB when you use this lib.
    4. You can also add a comment at the beginning of the global file, to be used as the documentation for the Lib Type.
    5. The project can contain as many forms as you need, but you must choose unique names when saving them to the project folder. Form1.xaml, Form2.xaml and Form3.xaml can cause troubles later, so, if you must, name them MyLib_Form1.xaml, MyLib_Form2.xaml and MyLib_Form3.xaml. Don't rename the files manually from windows explorer, and use the sVB project explorer to rename them, to do necessary changes to the .sb.gen file.
    6. Run the project to create the exe file in the Bin folder in the project folder.
    7. Now you can copy the Bin folder and paste in the sVB\Bin\Lib folder, then rename it to the name of your lib such as MyLib in this example. The name of this folder is not important, but Bin is not a suitable name, and of course you can't add tow libraries with folders named Bin because they will be merged, which can cause troubles later!
    8. Restart sVB, and in the code editor write the name of your library such as MyLib, then press dot. The auto completion list will show the members you declared in the global file and can use them. If you add comments to those members, you will get help info about them while typing.
      It is so simple. You can apply it on the Show Dialogs project in samples folder, but I advice to change the folder name to Dialogs instead, so, you can use this library like this:
      vb  
      Name = Dialogs.InputBox("Enter your name")  
      

    So, now you can create reusable code, and write your own libraries for sVB. In the past, this was available only by using C# and VB.NET to create SB and sVB libraries!
    Have fun.


  4. Small Visual Basic 411 Reputation points
    2022-10-30T19:54:17.873+00:00

    sVB v2.5 is just released:
    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.
    2. 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.
    3. 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 vb
      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: vb
      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:

       vb  
       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.
    2. 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.

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


  5. Small Visual Basic 411 Reputation points
    2022-11-02T16:58:03.543+00:00

    sVB v2.5.3 can now use external libraries written for Small Basic like LitDev.