Windows Forms for Small Basic v2 (Old thread)


extension

 

                      

                       

                              gungan37 – (IndyDev Software)

Hello guys! I have spent the past couple of days writing a new extension for Small Basic. Here is a screenshot of a program made with it:

 

  • The extension adds the following Windows Forms controls to Small Basic (** means that no other extension supports the control):

– Button

– RadioButton

– CheckBox

– ** Chart **

– Label

– ** LinkLabel **

– **NumericUpDown**

– **DateTimePicker**

– **MonthCalendar**

– ProgressBar

– TrackBar

– **RichTextBox**

– PictureBox

– **MaskedTextBox***

– **NotificationIcon***

– **ComboBox**

– **TreeView**

– **ListView**

Plus, it is 100% event driven! It is super easy to use! Just call WindowsFormsForSmallBasic.Setup() before you start and WindowsFormsForSmallBasic.InitializeForm() when all the controls are placed— this shows the form and hands off control to it. You may not modify the controls after this or write any more code outside of the event handlers. However, your event handlers can preform these operations.

Here is a sample (outdated, for v1): HMD046

And download link for the extension (outdated, for v1): http://www.mediafire.com/download.php?b8w679cqs6mpusr

Please ask any questions you make have and suggestions / bug reports are welcome too! I expect to add some more controls to the extension soon!

 

MS Small Basic: What are the Keywords of Small Basic?


Sin título2Examples:

If, Then, EndIf

If (Clock.Hour < 12) Then
TextWindow.WriteLine(«Good Morning World»)
EndIf

Else

We can shorten two if..then..endif statements to be just one by using a new word, else.

If we were to rewrite that program using else, this is how it will look:

If (Clock.Hour < 12) Then

TextWindow.WriteLine(«Good Morning World»)

Else TextWindow.WriteLine(«Good Evening World»)

EndIf

Goto

If (i < 25) Then

Goto start

EndIf

For, To, EndFor

For..EndFor is, in programming terms, called a loop.  It allows you to take a variable, give it an initial and an end value and let the computer increment the variable for you.  Every time the computer increments the variable, it runs the statements between For and EndFor.

This program prints out numbers from 1 to 24 in order:

For i = 1 To 24

TextWindow.WriteLine(i)

EndFor

Step

But if you wanted the variable to be incremented by 2 instead of 1 (like say, you wanted to print out all the odd numbers between 1 and 24), you can use the loop to do that too.

For i = 1 To 24 Step 2

TextWindow.WriteLine(i)

EndFor

While, EndWhile

The While loop is yet another looping method, that is useful especially when the loop count is not known ahead of time.  Whereas a For loop runs for a pre-defined number of times, the While loop runs until a given condition is true. In the example below, we’re halving a number until the result is greater than 1.

number = 100

While (number > 1)

TextWindow.WriteLine(number) number = number / 2

EndWhile

Sub, EndSub

A subroutine is a portion of code within a larger program that usually does something very specific, and that can be called from anywhere in the program.  Subroutines are identified by a name that follows the Sub keyword and are terminated by the EndSub keyword. Below is a program that includes the subroutine and calls it from various places.

PrintTime()

TextWindow.Write(«Enter your name: «)

name = TextWindow.Read()

TextWindow.Write(name + «, the time now is: «)

PrintTime()

Sub PrintTime

TextWindow.WriteLine(Clock.Time)

EndSub

And, ElseIf

If  percentage >= 75 Then

TextWindow.WriteLine(«The student’s grade is A.»)

  ElseIf  percentage < 75 And percentage >= 60  Then

TextWindow.WriteLine(«The student’s grade is B.»)

ElseIf  percentage < 60 And percentage >= 35 Then

TextWindow.WriteLine(«The student’s grade is C.»)

Else

TextWindow.WriteLine(«The student’s grade is D.»)

EndIf
Or

Sub subRainyCount

If Rainy = «y» Or Rainy = «Y» Then

RainyCount = RainyCount + 1

EndIf

EndSub