(translated by Google Translate)
Very interesting!..
I think sVB is going to be great!
:o)
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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!)
(translated by Google Translate)
Very interesting!..
I think sVB is going to be great!
:o)
A first glimpse: vSB 1.9 now compiles a project folder into one exe and allows to show multiple forms.
https://github.com/VBAndCs/sVB-Small-Visual-Basic/releases/tag/v1.9
The final brick for V2.0 is to allow a global.sb module to contain common functions and variables
This is a small visual basic code to generate a VB.NET colors class that can be used as an extension for Small Basic and sVB, with each property documented :).
See who the code is simple and organized, and try to write the same code with SB to realize how easy and powerful is the sVB compiler:
Sub Button1_OnClick()
TextBox1.AppendLine("Imports Microsoft.SmallVisualBasic.Library")
TextBox1.AppendLine(" Namespace WinForms")
TextBox1.AppendLine("''' <summary>")
TextBox1.AppendLine("''' Defines all known color names")
TextBox1.AppendLine("''' </summary>")
TextBox1.AppendLine("<SmallBasicType>")
TextBox1.AppendLine("public NotInheritable Class Colors")
ForEach color1 In Colors.AllColors
TextBox1.AppendLine(" ''' <summary>")
TextBox1.AppendLine(
Text.Format(" ''' [1] Color:", color1.Name)
)
TextBox1.AppendLine(
Text.Format(" ''' Hex: ""[1]""", color1)
)
TextBox1.AppendLine(
Text.Format(
" ''' R=[1], G=[2], B=[3]",
{color1.RedRatio, color1.GreenRatio, color1.BlueRatio}
)
)
TextBox1.AppendLine(" ''' </summary>")
TextBox1.AppendLine(" < ReturnValueType(VariableType.Color) >")
TextBox1.AppendLine(
Text.Format(
" public Shared ReadOnly Property [1] As Primitive = ""[2]""",
{color1.Name, color1}
)
)
TextBox1.AppendLine("")
Next
TextBox1.AppendLine("End Class")
TextBox1.AppendLine("End Namespace")
EndSub
This is the corresponding SB code. There is no Colors.AllColors property, nor Color class methods to get info about the color, so, I used an array to carry this info for only a three color. The code is longer than the max allowed comment, so, I will break it into two comments:
TextBox1 = Controls.AddMultiLineTextBox(0, 0)
Button1 = Controls.AddButton("Generate", 100, 100)
Controls.ButtonClicked = Button1_OnClick
Colors[1][1] = "Red"
Colors[1][2] = "#FF0000"
Colors[1][3] = "255"
Colors[1][4] = "0"
Colors[1][5] = "0"
Colors[2][1] = "Green"
Colors[2][2] = "#00FF00"
Colors[2][3] = "0"
Colors[2][4] = "255"
Colors[2][5] = "0"
Colors[3][1] = "Blue"
Colors[3][2] = "#0000FF"
Colors[3][3] = "0"
Colors[3][4] = "0"
Colors[3][5] = "255"
SB code part2
Sub Button1_OnClick
nl = Text.GetCharacter(13)
line = "Imports Microsoft.SmallVisualBasic.Library"
Code = code + line + Text.GetCharacter(13)
line = " Namespace WinForms"
Code = code + line + nl
line = "''' <summary>"
Code = code + line + nl
line = "''' Defines all known color names"
Code = code + line + nl
line = "''' </summary>"
Code = code + line + nl
line = "<SmallBasicType>"
Code = code + line + nl
line = "public NotInheritable Class Colors"
Code = code + line + nl
For i = 1 to 3
Color1 = colors[i]
line = " ''' <summary>"
Code = code + line + nl
line = " ''' " + color1[1] + " Color:"
Code = code + line + nl
line = " ''' Hex: " + Text.GetCharacter(34) + color1[2] + Text.GetCharacter(34)
Code = code + line + nl
line = " ''' R=" + color1[3] + ", G=" + color1[4] + ", B=" + color1[5]
Code = code + line + nl
line = " ''' </summary>"
Code = code + line + nl
line = " <ReturnValueType(VariableType.Color)>"
Code = code + line + nl
Tline = " public Shared ReadOnly Property " + color1[1] + " As Primitive = " + Text.GetCharacter(34) + color1[2] + Text.GetCharacter(34)
Code = code + line + nl
Code = code + nl
EndFor
line = "End Class"
Code = code + line + nl
ldLine = "End Namespace"
Code = code + line
Controls.SetTextBoxText(TextBox1, code)
EndSub