Page 1 of 2 12 LastLast
Results 1 to 40 of 57

Thread: Small Visual Basic: an educational language for kids and beginners

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Small Visual Basic: an educational language for kids and beginners

    Small Visual basic is based on Microsoft Small Basic. I tried to make it easier for kids starting from 6 years old. They can drag and drop controls on the form, and write one line code to show text or animate controls (see the animation samples in the samples folder that comes with language)
    Name:  2.jpg
Views: 1863
Size:  24.2 KB

    But I also made the language more powerful to introduce useful programming concepts to beginners until 17 years old.
    You can read about al the new features I added to the language here:
    https://github.com/VBAndCs/sVB-Small...ster/Readme.md

    I made the editor more like VS.NEt with Intellesense and allowed to preak code lines Like VB.NET, with auto formatting:
    Name:  3.jpg
Views: 2016
Size:  32.7 KB

    I even added features to sVB that is not supported in VB.NET itself, such as TimeSpan literals (#+1.12:15:30#) and auto-completion of font names in the editor.

    This is the sVB full reference book (750) pages:
    https://drive.google.com/file/d/1pCn...8MmutYCuXwpvjN

    It is also included in teh sVB installation folder. You can downlaod the installer from:
    https://marketplace.visualstudio.com...T.sVBInstaller

    For VB .NET programmers, sVB is a good practice on compilers, code editors, and form designers, as all theses components are fully written with VB.NET. The source code if fully published on github:
    https://github.com/VBAndCs/sVB-Small-Visual-Basic

    It is important to educate ourselves in compilers, to help evolving VB.NET itself. Anthony D. Green (the former PM of VB.NET language in Microsoft) has already published a pre-release of ModVB, the modern VB language built on top of VB.NET, and he has a plan to support ASP.NET core and mobile apps.
    So, please, prepare yourselves and your children for the future, and take the first step with sVB and be ready to support ModVB.
    Last edited by M.Hamdy; May 14th, 2023 at 12:36 PM.

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Visual Small Basic v1.8.5 for kids and beginners

    At the moment I don't have access to a pc with all the stuff I need to download and compile an entire project. Let alone download and install a program. But, where is the information regarding this program's installation?

    A tool to teach kids programming is nice, but if obtaining and installing it is too much hassle, it will probably be quickly ignored and people will go look for something else that's easier to install.
    Last edited by Peter Swinkels; Sep 19th, 2022 at 03:41 AM. Reason: typo's- LOL (what an idiot)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    Hi Peter Swinkels:
    You can download the sVB 1.8.5 release from this page:
    https://github.com/VBAndCs/sVB-Small...eases/tag/v1.8
    you will find the zip link at the bottom of the page.
    This is already mentioned in the readme file in the Download the language section:
    Go to the Releases page:
    https://github.com/VBAndCs/sVB-Small...Basic/releases
    navigate to the latest version of sVB, expand the Assets list at the bottom of the page, and download the ZIP file. Follow these instructions:
    1- 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
    2- Unzip the sVB.zip file. You will have a folder with the same name where you unzipped the file.
    3- Open the folder and double-click sVB.exe. And that it. You are ready to go
    Thanks.

  4. #4
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Visual Small Basic v1.8.5 for kids and beginners

    Impressive, but you should include a reference manual so people will know what your program can and can't do. Or add a button to the toolbar to open the relevant webpage.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    The zip file contains the ReadMe file. I will provide a more organized doc file when I hit V 2.0.
    The zip file also contains a link to the GitHub reop, where the readme file is viewed with format.
    And the zip contains a samples folder, where you can find a sample on each new feature in the language.
    I made more than 30 videos on my youtube channel(there is still about 20 unpublished videos) to introduce SB and sVB to kids, but it is in Arabic. I hope someone can do the same in English and other languages. We need to make kids know about this language, as it has the best of SB, VB6 and VB.NET mixed in the easiest way I could. My aim is to make sVB a gate for easy transfer to VB.NET.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    And of course, there are countless resources to learn the original SB, including the pdf that comes with MS SB. sVB is built on top of SB with a few break changes, so, all what the kid learns in SB will work in sVB. And he can apply SB samples in sVB directly, but he need to take care of variable domains, as SB has all variables global, but sVB has global and local variables.

  7. #7
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Visual Small Basic v1.8.5 for kids and beginners

    Out of curiousity, have other people that you know of tried this program? Were there any children among them? If you're serious about this project it would be a good idea to find out what your target audience thinks and wants.

  8. #8
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: Visual Small Basic v1.8.5 for kids and beginners

    Quote Originally Posted by Peter Swinkels View Post
    Out of curiousity, have other people that you know of tried this program? Were there any children among them? If you're serious about this project it would be a good idea to find out what your target audience thinks and wants.
    After firing the IDE it was at around 45 seconds mark when I became completely annoyed by not being able to implement even a simple "Hello world" in this as advertised "Kids BASIC Language" because neither MsgBox not MessageBox.Show functions seem to compile for no apparent reason. . . Ouch! I wouldn't recommend this to my worst foes TBH.

    cheers,
    </wqw>

  9. #9
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

    Re: Visual Small Basic v1.8.5 for kids and beginners

    Quote Originally Posted by wqweto View Post
    After firing the IDE it was at around 45 seconds mark when I became completely annoyed by not being able to implement even a simple "Hello world" in this as advertised "Kids BASIC Language" because neither MsgBox not MessageBox.Show functions seem to compile for no apparent reason. . . Ouch! I wouldn't recommend this to my worst foes TBH.

    cheers,
    </wqw>
    Only had a brief look at it myself and I am not really sure what benefits it would bring over just learning VB.Net - I think the fact variables don't seem to use "Dim" to declare them threw me completely.

  10. #10
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Visual Small Basic v1.8.5 for kids and beginners

    Quote Originally Posted by PlausiblyDamp View Post
    Only had a brief look at it myself and I am not really sure what benefits it would bring over just learning VB.Net - I think the fact variables don't seem to use "Dim" to declare them threw me completely.
    To be honest, I had the same issue. Which is why I said a manual would be useful. With a quick reference guide.

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    As said, sVB is based on SB. The compiler and syntax are very simplified, so, you can't call a method from a module without useing the qualified name.
    In small basic, you can show a message box on the graphics window like this:
    GraphicsWindow.ShowMessage("message", "title")
    This of course is stil working in sVB, but when tou are not using the graphics window, you should show the message over the form you want:
    Form1.ShowMessage("message", "title")
    If you want to show the massage without being owned by any form, show it from the Forms module:
    Forms.ShowMessage("message", "title")
    I am keeping sVB compatible with SB not to loose a 14 years of SB legacy code, tutorials, videos and experience. SB is taught in many schools in many counties, and I must keep as close as possible to what teachers already know, because they are not programmers in first place, and if they didn't understand the language and its samples, no way they can teach it to kids. Also, I must preserve the tubers experience and video legacy, hoping these tubers can introduce sVB to their viewers building up on their existing video content without reinventing the wheel.
    So, in short:
    If you are not an SB teacher, or have a son to teach him sVB, don't mind the language syntax. It is not for you. You can only look at the VB.NET source code to understand how the compiler works. Then if you have a new vision for the language syntax, such as adding VB6 intrinsic functions, please go ahead and fork the language to implement your vision and introduce it to the world.

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    For those who are willing to teach sVB to kids, take a look first at SB pdf from Microsoft:
    https://download.microsoft.com/downl...ll%20Basic.pdf

    You can try the samples from the book in sVB, which has a better editor and intellesense. But keep in mind that all small basic variables are global, even if you defined them in subroutines! This is not the case in sVB, so, it will give you errors about variables used without declaration. In sVB you can pass arguments to subs, and return values from function, which are not valid in SB. But if you want to keep it simple, just declare the variable that causing the error at the top of the file, by assigning it to 0, "" or {} regarding it's purpose. sVB and SB are dynamic languages, and you move values from any variable to another regardless it's initial values.
    But if this confuses you, just download SB and take it step by step.
    If you are a VB6 or a VB.NET, you can finish the pdf in one session.

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    There are also many videos about SB. This one has 92k views, introduced by a child
    https://www.youtube.com/watch?v=fR9w0vQAMtg

  14. #14
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Visual Small Basic v1.8.5 for kids and beginners

    And what do teachers and their students (or parents and their children) say in their reviews? If there are any...

  15. #15
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    Re: Visual Small Basic v1.8.5 for kids and beginners

    [Also see https://www.vbforums.com/showthread....4#post5580704]

    Note my comment post #7.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  16. #16
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Visual Small Basic v1.8.5 for kids and beginners

    Also, why is this being made other than the assumption anyone is actually interested in this project based on perceived technological superiority? (variable scope, etc.) To make money? If so, good luck trying to compete with a product backed by a large company such as Microsoft. This project is likely going to remain unnoticed and ignored except by people who are interested in the technical stuff behind it.

    Unless there's an entire team behind this with the means to distribute and support this, I say this is going to go nowhere.

    EDIT:
    However truth be told, it takes a level of skill to make something like this. How did you learn programming btw?
    Last edited by Peter Swinkels; Sep 20th, 2022 at 10:14 AM. Reason: I am an idiot

  17. #17

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    Quote Originally Posted by PlausiblyDamp View Post
    Only had a brief look at it myself and I am not really sure what benefits it would bring over just learning VB.Net - I think the fact variables don't seem to use "Dim" to declare them threw me completely.
    seems that you don't know it was the default mode of VB until VB5, and is still valid today in VB.NET.. Try this:
    Code:
    Option Explicit Off
    Option Strict Off
    
    Module Test
        Public Sub Main()
            x = 1
            y = 2
            z = x + y
        End Sub
    
    End Module
    All vars x, y, and z are implicitly declared as object. This is what happens in Small Basic and sVB, with one difference, that all vars are declared to be primitive, which is a structure that do all the runtime job of small basic, and can hold a number, a string, or a dictionary that serves as an array. I extend this to allow it to handle Dates and TimeSpans also, as they are stored as a number (Date.ticks, TimeSpan.Ticks), which requires minimum change of the primitive design.

    The goad of designing Small Basic to work only in Visual Basic dynamic mode, is to avoid confusing kids with types, conversions, type mismatch, and allow them to deal with basic date types easily. I kept the same model but improved it with inferring types from initial values, to allow using vars as objects by calling extension methods with auto-completion support. This makes code shorter and easier, but the language still dynamic and vars can hold any values, which is useful in method params. In general, kids should be thought to give vars meaningful names and make them deal with specific data types, so they can have better organized code, with better editor support.
    Last edited by M.Hamdy; Sep 22nd, 2022 at 11:53 AM.

  18. #18

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    Quote Originally Posted by Peter Swinkels View Post
    However truth be told, it takes a level of skill to make something like this. How did you learn programming btw?
    I built on the SB source code. There is published a version of it (written in C#):
    https://github.com/sb/smallbasic-edi...Basic.Compiler
    but I got the desktop version by decompiling SB.exe and other dlls, converted it to VB.NET, added a form designer I crated in 2014 as a generic diagram designer, then modified the compiler over the past tow years. As I said, this is my playground to train my self before diving into Roslyn, as I am willing to evolve VB.NET itself. Luckly Anthont D.. Green has the same goal with a deeper experince of Roslyn, and he pre-released ModVB last month, which made me try to finish sVB to switch to ModVB. I am taking the final step in sVB now, by modifying the compiler to build a project containing multi forms and on global.sb file that contains public vars and subroutines to be used in all forms. The designer already allows to design multi forms, but the compiler can only compile on sb file until now. I expect to publish sVB 2.0 with the project concept in a month, then switch to ModVB.

  19. #19
    Hyperactive Member gaouser's Avatar
    Join Date
    Mar 2022
    Location
    Near the User32.dll
    Posts
    386

    Re: Visual Small Basic v1.8.5 for kids and beginners

    hi. what vb do you use when making it

  20. #20
    Hyperactive Member gaouser's Avatar
    Join Date
    Mar 2022
    Location
    Near the User32.dll
    Posts
    386

    Re: Visual Small Basic v1.8.5 for kids and beginners

    Quote Originally Posted by Peter Swinkels View Post
    Also, why is this being made other than the assumption anyone is actually interested in this project based on perceived technological superiority? (variable scope, etc.) To make money? If so, good luck trying to compete with a product backed by a large company such as Microsoft. This project is likely going to remain unnoticed and ignored except by people who are interested in the technical stuff behind it.

    Unless there's an entire team behind this with the means to distribute and support this, I say this is going to go nowhere.

    EDIT:
    However truth be told, it takes a level of skill to make something like this. How did you learn programming btw?
    nowdays microsoft just wants money. it doesnt make helpful programs or updates for program
    after .net, microsoft make everyone angry. it has realy bad errors when migrating, com ports are really bad,socket is slower than winsock.

  21. #21

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    Quote Originally Posted by gaouser View Post
    hi. what vb do you use when making it
    The source code is fully written in VB.NET, using WPF as the UI framework:
    https://github.com/VBAndCs/sVB-Small-Visual-Basic

  22. #22
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Visual Small Basic v1.8.5 for kids and beginners

    M.Hamdy, you learned programming without this "improved" sb... Everyone else did too. What makes you think your project is worthwhile?

    @gaouser: I have no idea what you're complaining about. Also, any sensible company would want to make money... Kinda the point of a company. Microsoft always wanted money, however they're apparently not making something you want. Unless they're a bunch of idiots they will make and keep making software that's good enough for most people. Otherwise they'll be going bankrupt.
    Last edited by Peter Swinkels; Sep 25th, 2022 at 05:26 AM.

  23. #23

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    [QUOTE=Peter Swinkels;5581212]M.Hamdy, you learned programming without this "improved" sb... Everyone else did too. What makes you think your project is worthwhile?

    I stated learning programming with VB4 at age 21. VB4 back then was easier than Microsoft Small Basic, and this is why I decided to create Small Visual Basic. Also, today a kid under 15 years can't easily learn C# nor VB.NET... etc as languages grown too complex over time, and VS.NET IDE is too crowded and heavy to install. In fact the basic problem now is that many kids have tablets and mobiles not PCs and it is not easy to write code on such devices.

  24. #24

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    sVB 1.9 now compiles a project!
    https://github.com/VBAndCs/sVB-Small...eases/tag/v1.9
    You can design many forms in the form designer, save them to the same folder, which will become the project folder. When you open any form of this project and run it, sVB will compile all the forms into one exe (that will have the name of the folder/project).
    You can show form2 (for example) from form1 using this code:
    ```vb
    form2 = Forms.ShowForm("form2", {1, 2, 3})
    form2.BackColor = Colors.AliceBlue
    ```

    The ShowForm method will do the following:
    1. Load the design of the form2 from its xaml file.
    2. pass the argsArr data sent to its second parameter to the ArgsArr property of the form, so you can use it as you want. The argsArr can be a single value, and array of values, or a dynamic object with dynamic properties, so, you can pass any data you want between the forms.
    3. Execute the code written in the global area of the code file of form2. You can use Form2.ArgsArr in this global area to initialize the form. Ex:
    ```VB
    TextBox1.Text = Me.ArgsArr
    ```

    Note that global code is executed only when the form is opened for the first time, or after it is closed then re-opened. It will not be executed if you hided or minimized the form then showed it again.
    4. Show Form2.
    5. Fire the OnShown Event of the form. You can use it also to initialize the form:
    ```vb
    Sub Form2_OnShown()
    data = Me.ArgsArr
    TextBox1.Text = data[3]
    EndSub
    ```

    This event has two advantages over using the global code area to initialize the form:
    a. It will be executed every time you call Forms.ShowForm, so, you can use the passed argsArr data every time you show the form even it is still open.
    b. It is the only way to interact with the form if it is shown as a dialog (modal window). You can do this by calling Forms.ShowDialog instead of Forms.ShowForm. The dialog window stops executing the code until the user closes it, so any code in the global area will never be executed. Also, trying to set the BackColor of the form as in the next example will have no effect, since it will be executed only after the form is closed:
    ```vb
    form2 = Forms.ShowDialog("form2", "Test")
    form2.BackColor = Colors.AliceBlue
    ```

    For a simple sample, see the `Random Buttons 2` sample in the samples folder. It is a modified version of the `Random Buttons` sample, which uses code to define and show another form. In the new version, the second form is designed by the form designer.

    Note that the form you run the program from will be main form of the project (the startup form). This allows change the startup form as you want by just open the form code and press F5, so you can easily test project forms.
    In the upcoming sVB 2.0, I will show a list of project forms, and I will allow to define a `global.sb` file in each project, so you can add variables and subroutines that are global to all the project and can be accessed from any form. This will allow to create a "Random Buttons 3" sample, where the `CreateRndButton(onForm)` function can be moved to the global.sb file, so it can be used from both form1 and form2.

  25. #25
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Visual Small Basic v1.8.5 for kids and beginners

    [QUOTE=M.Hamdy;5581288]
    Quote Originally Posted by Peter Swinkels View Post
    M.Hamdy, you learned programming without this "improved" sb... Everyone else did too. What makes you think your project is worthwhile?

    I stated learning programming with VB4 at age 21. VB4 back then was easier than Microsoft Small Basic, and this is why I decided to create Small Visual Basic. Also, today a kid under 15 years can't easily learn C# nor VB.NET... etc as languages grown too complex over time, and VS.NET IDE is too crowded and heavy to install. In fact the basic problem now is that many kids have tablets and mobiles not PCs and it is not easy to write code on such devices.
    Vb4 easier than Small BASIC? If you say so. I don't think getting the hang of vb.net/C#'s core features is that hard. I think finding the proper resources to learn from is the bigger problem. And unless you have some cheap peace of crap our outdated pc vs.net's IDE being too heavy to install is nonsense. So, many kids have mobiles and tablets? Probably true, that raises an even bigger question: does your supposedly superior learning environment run on tablets? Otherwise, what argument are you trying to make?

  26. #26
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    Re: Visual Small Basic v1.8.5 for kids and beginners

    I don't use Basic but IMO the issue for 'kids/beginners' isn't so much the language per say, it's getting to grips with the IDE. VS/VS Code are quite complex and you really need to know how to use it to use it. IMO what would be helpful is a cut-down simplified IDE that is 'intuitive' to those kids used to mobiles/tablets. Once they're then familiar with programming then they can progress to the 'grown-up' full IDE version.

    Just my 2 cents...
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  27. #27
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: Visual Small Basic v1.8.5 for kids and beginners

    This is beginning to look like Microsoft should simply add a basic (pun not intended) mode to their IDE... Quick BASIC used to have a "full menus" option or something.

  28. #28

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    Quote Originally Posted by 2kaud View Post
    IMO what would be helpful is a cut-down simplified IDE that is 'intuitive' to those kids used to mobiles/tablets. Once they're then familiar with programming then they can progress to the 'grown-up' full IDE version.

    Just my 2 cents...

    You can do it if you want. The Small Visual basic project offers you a simple ID with a form designer and a code editor, and all you need to do is:
    1. replace the sVB compiler with a VB.NET compiler. This is easy by using Roslyn, which can parse, compile and build VB.NET codes for you, and provides you with all languages services. It is even possible to provide some new syntax, and trick Roslyn to parse it as a VB.NET syntax, as I did in this project:
    https://github.com/VBAndCs/VB-Record-Source-Generator
    2. The code editor will need some few modifications to support syntax differences between sVB and VB.NET.
    3. Remove the small basic literary and use .NET Core instead. This will not need any work of you except adding the necessary SDK dependency to the VBCompiler.
    So, go for it. It can be an attractive transmission from SB and sVB to VB.NET.

  29. #29

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    This is a sVB code to generate a VB.NET class that can be used in small basic lib. I Wrote this code to generate xml documentation to about 140 color name property in the Colors class. Writing the same code with MS Small Basic will be 2 or 3 times this size, with very vary long lines or many intermediate Ines to break long lines. This code works in sVB v1.9.7:
    https://github.com/VBAndCs/sVB-Small...eases/tag/v1.9

    Code:
    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

  30. #30

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    This is a SB code that does the same job. There is no Colors.AllColors property, so, I simulated it with an array that contains three colors only:
    Code:
    TextBox1 = Controls.AddMultiLineTextBox(0, 0)
    Button1 = Controls.AddButton("Generate", 100, 100)
    Controls.ButtonClicked = Button1_OnClick
    
    Sub Button1_OnClick
      line = "Imports Microsoft.SmallVisualBasic.Library"
      Code = code +  line + Text.GetCharacter(13)
      
      line = "   Namespace WinForms"
      Code = code +  line + Text.GetCharacter(13)  
      
      line = "''' <summary>"
      Code = code +  line + Text.GetCharacter(13)
      
      line = "''' Defines all known color names"
      Code = code +  line + Text.GetCharacter(13)
      
      line = "''' </summary>"
      Code = code +  line + Text.GetCharacter(13)
      
      line = "<SmallBasicType>"
      Code = code +  line + Text.GetCharacter(13)
      
      line = "public NotInheritable Class Colors"
      Code = code +  line + Text.GetCharacter(13)
      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"
      
      For i = 1 to 3
        Color1 = colors[i]
        line = "  ''' <summary>"
        Code = code +  line + Text.GetCharacter(13)
        
        line = "  ''' " + color1[1] + " Color:"
        Code = code +  line + Text.GetCharacter(13)
        
        line = "  ''' Hex: " + Text.GetCharacter(34) + color1[2] + Text.GetCharacter(34)
        Code = code +  line + Text.GetCharacter(13)
        
        line = "  ''' R=" + color1[3] + ", G=" + color1[4] + ", B=" + color1[5]
        Code = code +  line + Text.GetCharacter(13)
        
        line = "  ''' </summary>"
        Code = code +  line + Text.GetCharacter(13)
        
        line = "  <ReturnValueType(VariableType.Color)>"
        Code = code +  line + Text.GetCharacter(13)
        
        Tline = "  public Shared ReadOnly Property " + color1[1] + " As Primitive = " + Text.GetCharacter(34) + color1[2] + Text.GetCharacter(34)
        Code = code +  line + Text.GetCharacter(13)
        
        Code = code +  Text.GetCharacter(13)
      EndFor
      
      line = "End Class"
      Code = code +  line + Text.GetCharacter(13)
      
      ldLine = "End Namespace"
      Code = code +  line + Text.GetCharacter(13)
      
      Controls.SetTextBoxText(TextBox1, code)
    EndSub

  31. #31

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    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...eases/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.

  32. #32

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    sVB V2.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:
    Code:
    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:
    Code:
    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:
    Code:
    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:

  33. #33

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    I took this further in sVB 2.2.5. It now allows to add the GeometricPath to the Label control too, so, it is possible to draw complex shapes on the form. In fact this was possible by adding a new figure in the Toolbox folder, so, it can be dragged on the form, but doing this requires a good knowledge of XAML, which is not something to expect from kids and beginners. Now, anyone can write sVB code to create whatever shapes he wants.
    You can create the geometric path as usual, then add it to a label, by calling the AddGeometricPath() method of this label:
    Code:
    Label1.AddGeometricPath(
    Colors.Red, ' Pen color
    2, ' Pen width
    Colors.Yellow ' Brush color
    )
    
    Label1.Rotate(45)
    The advantage of adding shapes to the label, is that you can handle their events.
    See the Geometric Path 2 in the samples folder. It adds the same shapes of the previous sample to the form, and allows you to drag them by the mouse.

  34. #34

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    sVB 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:
    Code:
    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.

  35. #35
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Visual Small Basic v1.8.5 for kids and beginners

    @M.Hamdy

    Excellent job. Your compiler works (until now).

    Missing options:
    1. Step by Step execution which can show line of code before execution.
    2. Put a Serial Port communications object. Then this can be used to handle Arduino (which may have a specific "parser", to read commands from sVB, in c++, but as black box for the children). The exercise/practice has to consist of specific Arduino code and hardware, and the preparation of a nice sVB code to handle (with some variations). So you get STEM (science, technology, engineering, and mathematics) systems which are good for education.


    That's for the time.

  36. #36

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic v1.8.5 for kids and beginners

    @georgekar
    Thanks for your feedback.
    Debugging is not supported in this stage. The original SB source code has some sort of edugging support, but it was never enabled, so, I may look at it someday.
    Right now, I am about to release sVB 2.5, which is a ready for production version, focusing on completing the mimi winforms framework, and building an sVB notepad app sample.

    I have no experience with Arduino, but sVB (like SB) is extensible. SB has many advanced libraries written with C#, but unfortunately they will not work in sVB unless modified to target the SmallVisualBasicLibrary.dll instead of SmallBasicLibrary.dll.
    But otherwise, the same rules can be applied to create external libraries for sVB. Besides, sVB can create libraries for itself (as explained in the previous post).
    So, I advice you to create a C# or a VB.NET lib to offer the serial communication and Arduino support. Instructions here, but just use SmallVisualBasicLibrary.dll instead of SmallBasicLibrary.dll:
    https://techcommunity.microsoft.com/...ic/ba-p/335290

  37. #37

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic for kids and beginners

    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.

    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.

    4. 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()
    ```

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

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

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

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

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

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

  38. #38

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic for kids and beginners

    Create an external library for sVB:
    sVB 2.5.5 can use existing external libraries created for Small Basic (like LitDev). Just insert those libraries dll files in the Lib folder of sVB 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...xtensions.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 targetting `.NET Framework 4.8` and refrencing 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 samoles folder.

  39. #39

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic for kids and beginners

    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.

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

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

  40. #40

    Thread Starter
    Lively Member
    Join Date
    Apr 2020
    Posts
    83

    Re: Visual Small Basic for kids and beginners

    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.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width