github VBAndCs/sVB-Small-Visual-Basic v1.7
Small Visual Basic V1.7.5

latest releases: v2.8, v2.7, v2.6...
2 years ago

What's new in sVB v1.7

  1. Add ForEach statement to the language. It is easier for iterating through arrays that have items with string keys. Ex:
   arr[1] = "One" 
   arr["test"] = "Hello"
   arr!Name = "Ahmad"  
   ForEach item In arr
      TextWindow.WriteLine(item)
   Next

The above code will print:

One
Hello
Ahmad
  1. Add Append and AppendLine methods to the TextBox control, and Items and RemoveAllItems to the ListBox control. See the For Each Sample in the Samples folder.

  2. Infer var types from initial values. This allows to call some methods directly from the var name. For example:

x = "abc"
x = x.Append("efg")
TextWindow.WriteLine(x) ' abcefg

Note That:

  • string variables call methods of the Text class.
  • double (numertic) variables call methods of the Math class.
  • color variables call methods of the Color class.
  • array variables call methods of the Array class.

The editor intellisense provides you with info about the var type and auto completion list shows the available methods it can call.
Note that:

  • sVB is still a dynamic type language, so, you can still store any value in the variable regardless its inferred type. I don't advice you to do that, as you should keep your code clean and readable.
  • sVB can't infer the type in some cases, such as:
  • you initialize the var from a call to a function you wrote.
  • you initialize the var from a calculated expression or operator, even a simple addition one, as sVB will decide the value at runtime only.
  • sub and function params can't be inferred unless you named them using one of the naming conventions for data, controls, colors and keys.

In such cases, you can initialize the var with "" for strings, 0 for numerics, or {} for arrays, then add the value to it in the next line.

  1. Variables that contain the word color is considered to be a Color and when you assign a value for them, the auto completion list suggests the Colors class to choose a color from it's members.
    The same for the word key, which is considered to be a Key, and auto completion offers the Keys class to choose from its members. This makes it easy to deal with the pressed key in Keyboard events, such as using the Event.LastKey property.

Don't miss a new sVB-Small-Visual-Basic release

NewReleases is sending notifications on new releases.