Results 1 to 30 of 30

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

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2020
    Posts
    49

    Visual Small Basic v1.8.5 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: 236
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: 233
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.

    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; Sep 18th, 2022 at 05:29 PM.

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

    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
    Member
    Join Date
    Apr 2020
    Posts
    49

    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,567

    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
    Member
    Join Date
    Apr 2020
    Posts
    49

    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
    Member
    Join Date
    Apr 2020
    Posts
    49

    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,567

    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
    Posts
    4,115

    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
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,897

    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,567

    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
    Member
    Join Date
    Apr 2020
    Posts
    49

    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
    Member
    Join Date
    Apr 2020
    Posts
    49

    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
    Member
    Join Date
    Apr 2020
    Posts
    49

    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,567

    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
    793

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

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

    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
    Member
    Join Date
    Apr 2020
    Posts
    49

    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
    Member
    Join Date
    Apr 2020
    Posts
    49

    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
    Turkey
    Posts
    281

    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
    Turkey
    Posts
    281

    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
    Member
    Join Date
    Apr 2020
    Posts
    49

    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,567

    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
    Member
    Join Date
    Apr 2020
    Posts
    49

    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
    Member
    Join Date
    Apr 2020
    Posts
    49

    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,567

    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
    793

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

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

    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
    Member
    Join Date
    Apr 2020
    Posts
    49

    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
    Member
    Join Date
    Apr 2020
    Posts
    49

    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
    Member
    Join Date
    Apr 2020
    Posts
    49

    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

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