Beruflich Dokumente
Kultur Dokumente
http://www.computerscienceforkids.com/Pages/Microsoft-Small-Basic-For-Kids-A-ComputerProgramming-Tutorial-by-Philip-Conrod-and-Lou-Tylee.aspx
SMALL BASIC FOR KIDS In the 1980's, there was a series of books aimed at teaching kids
how to use the Basic programming language. Titles like "Kids and the Apple II", "Kids and
the Commodore 64," and "Kids and the IBM-PC" were sold everywhere. These books sold
over 700,000 copies! With permission and editorial help from the original author, we have
adapted these classic books to the new Microsoft Small Basic language - a language
aimed at encouraging kids to learn programming.
SMALL BASIC FOR KIDS (Table of Contents) is an illustrated introduction to computer
programming that provides an interactive, self-paced tutorial to the new Small Basic
programming environment. The book (using many of the original cartoon drawings)
consists of 30 short lessons that explain how to create and run a Small Basic program.
Students learn about program design and many elements of the Small Basic language.
Numerous examples are used to demonstrate every step in the building process. The
1
tutorial also includes two complete games for students to build and try - a text-based
Hangman game and a simple video game (Sample Screen Shots). SMALL BASIC FOR KIDS
should be understandable to kids aged 10 to 12 and is suitable for both home and
classroom use. Notes for both the instructor ( or parent) and the students are
provided. Assignments are given to test student knowledge. No programming experience
is necessary, but familiarity with doing common tasks using Windows is expected.
It requires a Microsoft Windows operating system (XP, Vista, or Windows 7), ability to view
and print documents saved in Microsoft Word format, and Small Basic (Version 0.9 or
higher, a free download from Microsoft)
ORDERING AND DELIVERY OPTIONS
All of our tutorials are available in a downloadable Microsoft Word (v97+) and PDF E-Book
format. The entire E-Book and/or selected chapters can be printed on your local printer
and/or viewed on your computer screen. The E-Books can be downloaded from our
website immediately after purchase . We compress all these files using a .zip format to
help reduce the size for faster downloading.
If you are a full time school teacher, we also sell this E-Book Tutorial in an Annual
Unlimited User Site License Teacher Edition. Our Teacher Edition allows you to distribute
the tutorial and source code to any of the students who attend your computer science
class. You can customize and personalize the tutorial and the associated source code to fit
your unique teaching style whether the class is self study or instructor led. Since this
Tutorial is distributed in an editable Microsoft Word format you can add your own
teaching text and/or notes around our teaching text. You can add your own diagrams
and/or personalize the E-Book tutorial to fit your specific teaching needs. Unlike other
Tutorials that are Paper or PDF based, you can modify our teaching narrative and source
code inside the tutorial and reprint as needed. This unique flexibility sets us apart from all
other tutorials on the market. We also sell special large scale multi-teacher site license
agreements for School Districts and Online Schools. Please contact us directly if you are
interested in a large scale license agreement via the Contact Us tab above. These special
large scale licenses are not sold via this webpage.
Click on any of the "Add to Cart" options on the left of this page to select your preferred
delivery option
INTRODUCTION TO PROGRAMMING
2
1. Getting Started
2. Sounds and Strings
3. Editing Lines
4. Fixing Lines and Syntax Errors
5. Read Statement
6. Write and ReadNumber
7. Assignment Statement
8. Goto, Stopping a Program
9. If Statement
10. Introducing Numbers
11. Delays and Random Numbers
12. The If Statement with Numbers
13. For Loops
14. Saving and Opening Programs
GRAPHICS
15. Text Graphics
16. Graphics Window, Drawing Lines
17. Drawing Shapes
18. Drawing Text
19. Turtle Graphics
Walking Boxes:
Exploding Lines:
Colorful Circles:
Hangman Game:
After you double click on the e-junkie download link, please "save as" the compressed .zip file in your
Downloads or My Documents folder. If you are using Windows XP or Windows 7 you can right click on the
downloaded .zip file an extract all the files in the recommended subdirectory (under your My Documents
folder). After the files are extracted, navigate to the Starthere.doc file in the Tutorial subdirectory for further
instructions on how to use the tutorial. The .downloaded zip file contains all the tutorial chapters and
solution source code answer files you will need to complete the self-study course.
Blog Post: Small Basic for Little Kids Series #02 Loop
Ray FAST
The single most important concept in programming is loop, I think. And yet, it's (usually) not an easy concept for kids to
grasp. I remember when I was young, I had to struggle with the idea of loop and N=N+1. Back then, a loop in BASIC
might look like this: 10 PRINT "123" 20 GOTO 10 GOTO statement...
on7 Jan 2013
Blog Post: Small Basic for Little Kids Series #01 A Typing Game
6
Ray FAST
Its always fun to teach the little ones to learn and do something. Teaching programming is no different. As previously
mentioned, I have been on the lookout for a fun and low-barrier language for beginners, a third grader to be exact. So
far, all in all, Ive spent about 20-30 hours...
on3 Dec 2012
http://blogs.msdn.com/b/smallbasic/archive/tags/small+basic+for+little+kids/
Ray FAST
9 Jun 2013 6:03 PM
It was a beautiful sunny weekend, and wife's mandate of father-son bonding was to be
obeyed... So, after a bike ride, it's time for some coding. Small Basic, that is.
My little boy has been bugging me about game programming. After some convincing, he
settled on Pong, not entirely sure what Pong is.
Having in mind to post the process to the blog, we saved multiple versions of the code, so
to show the progress. I think he is still too young to understand version control :)
Version 1:
' make background
GraphicsWindow.Width = "700"
GraphicsWindow.Height = "500"
'set pen
GraphicsWindow.PenColor = "gray"
GraphicsWindow.PenWidth = "50"
'draw border
GraphicsWindow.DrawRectangle(0,0,700,500)
' set brush
GraphicsWindow.BrushColor = "white"
' make goals, size 100, from (0,200) to (0,300)
GraphicsWindow.FillRectangle(0,200,26,100)
GraphicsWindow.FillRectangle(674,200,26,100)
' set brush
GraphicsWindow.BrushColor = "black"
'make ball
GraphicsWindow.FillEllipse(345,245,10,10)
'make paddles
GraphicsWindow.FillRectangle(30,220,10,60)
GraphicsWindow.FillRectangle(664,220,10,60)
It's pretty straightforward. The only question I had for him was why 700x500 for the
graphic window. Personally, I'd go with 800x600, or1024x768. You know the whole
VGA/SVGA thing :)
His reply was that he always use 700x500 for the graphics window.
One thing worth noting is that BrushColor and PenColor are for difference purposes. The
former for filling an object, the latter for drawing an object.
Version 2:
In V2, we added the wall for bouncing from left to right (X coordinates). I gave him the
idea that the illusion of a ball moving is achieved by repeatedly drawing and erasing a ball
in a new position.
The speed of the ball movement can be adjusted by two factors:
Timer.interval and step size in moving in X direction.
The part of making the ball bounced off the wall seemed like a magic. In reality it is
nothing but flipping the corresponding step size (StepX) to the negative.
In fact, I made him to pretend to be a ball, and count out loud the steps, walk towards the
wall, and "bouncing" off the wall. After a couple times, he got it :)
' v2
' bounces well, left to right
' make background
GraphicsWindow.Width = "700"
GraphicsWindow.Height = "500"
'set pen
GraphicsWindow.PenColor = "gray"
GraphicsWindow.PenWidth = "50"
'draw border
GraphicsWindow.DrawRectangle(0,0,700,500)
LeftWallX = 27
RightWallX = 660
DrawBall()
Sub RunGame
EraseBall()
BallX = BallX + StepX
BallY = BallY + StepY
' Hit right wall
If BallX >= RightWallX Then
StepX = -StepSize
EndIf
' Hit left wall
If BallX <= LeftWallX Then
StepX = StepSize
EndIf
DrawBall()
EndSub
Version 3:
In V3, we handled bouncing the wall up and down. This mirrors what's done in V2, except
using StepX as opposed to StepY. When put together, the ball can now bounces off all 4
walls (disregarding the goals and paddles). It almost seemed magical.
' v3
' bounces well, left to right, and up and down.
' make background
GraphicsWindow.Width = "700"
GraphicsWindow.Height = "500"
'set pen
GraphicsWindow.PenColor = "gray"
GraphicsWindow.PenWidth = "50"
11
'draw border
GraphicsWindow.DrawRectangle(0,0,700,500)
' set brush
GraphicsWindow.BrushColor = "white"
' make left goal, size 100, from (0,200) to (0,300)
GraphicsWindow.FillRectangle(0,200,26,100)
' make right goal, size 100, from (674,200) to (674,300)
GraphicsWindow.FillRectangle(674,200,26,100)
' set brush
GraphicsWindow.BrushColor = "black"
' make paddles
GraphicsWindow.FillRectangle(30,220,10,60)
GraphicsWindow.FillRectangle(664,220,10,60)
' draw ball
Sub DrawBall
GraphicsWindow.BrushColor = "black"
GraphicsWindow.FillEllipse(BallX,BallY,10,10)
EndSub
' erase ball
Sub EraseBall
GraphicsWindow.PenWidth = "2"
GraphicsWindow.BrushColor = "white"
GraphicsWindow.FillEllipse(BallX,BallY,10,10)
GraphicsWindow.PenColor = "white"
GraphicsWindow.DrawEllipse(BallX,BallY,10,10)
EndSub
' sleep
Timer.Interval = 1
Timer.Tick = RunGame
StepSizeX = 2
StepSizeY = 2
StepX = StepSizeX
StepY = StepSizeY
12
BallX=345
' BallY=245
BallY=100
' Edges of the 4 walls
LeftWallX = 27
RightWallX = 660
TopWallY = 27
BottomWallY = 460
DrawBall()
Sub RunGame
EraseBall()
' Calculate the new position for ball
BallX = BallX + StepX
BallY = BallY + StepY
' Hit right wall
If BallX >= RightWallX Then
StepX = -StepSizeX
EndIf
' Hit left wall
If BallX <= LeftWallX Then
StepX = StepSizeX
EndIf
' Hit bottom wall
If BallY >= BottomWallY Then
StepY = -StepSizeY
EndIf
' Hit top wall
If BallY <= TopWallY Then
StepY = StepSizeY
EndIf
DrawBall()
EndSub
13
Version 4:
In V4, we took care of bouncing the ball of paddles.
14
StepSizeX = 2
StepSizeY = 2
StepX = StepSizeX
StepY = StepSizeY
BallX=345
' BallY=245
BallY=245
' Edges of the 4 walls
LeftWallX = 27
RightWallX = 660
TopWallY = 27
BottomWallY = 460
DrawBall()
DrawLeftPaddle()
DrawRightPaddle()
Sub RunGame
EraseBall()
' Calculate the new position for ball
BallX = BallX + StepX
BallY = BallY + StepY
' Hit right wall
If BallX >= RightWallX Then
StepX = -StepSizeX
EndIf
' Hit left wall
If BallX <= LeftWallX Then
StepX = StepSizeX
EndIf
' Hit bottom wall
If BallY >= BottomWallY Then
StepY = -StepSizeY
EndIf
16
Version 5:
In V5, we made the paddles movable.
The trick here is to add the events to handle key. First we used KeyDown event.
For reasons I don't understand, the little fellow insisted that the left player should use "W"
for up and "S" for down, while the right user uses Up Arrow for up, and Down Arrow for
down.
During testing, I had this line added to event handler:
GraphicsWindow.Title = "'" + LastKey + "' pressed"
That way, it's easier to tell which key was pressed (or released rather), and what's the
corresponding value should be used in the code.
17
20
Sub RunGame
EraseBall()
' Calculate the new position for ball
BallX = BallX + StepX
BallY = BallY + StepY
' Hit right wall
If BallX >= RightWallX Then
StepX = -StepSizeX
EndIf
' Hit left wall
If BallX <= LeftWallX Then
StepX = StepSizeX
EndIf
' Hit bottom wall
If BallY >= BottomWallY Then
StepY = -StepSizeY
EndIf
' Hit top wall
If BallY <= TopWallY Then
StepY = StepSizeY
EndIf
' Hit right paddle
If (BallX >= RightPaddleX-12) And (BallY >= RightPaddleY) And
(BallY <= RightPaddleY+60) Then
StepX = -StepSizeX
DrawRightPaddle()
EndIf
' Hit left paddle
If (BallX <= LeftPaddleX+12) And (BallY >= LeftPaddleY) And
(BallY <= LeftPaddleY+60) Then
StepX = StepSizeX
DrawLeftPaddle()
EndIf
21
DrawBall()
EndSub
Version 6:
In V6, we solved the two-player problem.
We found it to be problematic, when both players try to hold the key down at the same
time. The program can only respond to one.
I had the idea of instead to handle KeyUp event. That way it will force players to hit the
keys instead of holding the keys down and don't let it go.
22
StepX = StepSizeX
StepY = StepSizeY
BallX=345
' BallY=245
BallY=245
' Edges of the 4 walls
LeftWallX = 27
RightWallX = 660
TopWallY = 27
BottomWallY = 460
DrawBall()
DrawLeftPaddle()
DrawRightPaddle()
Sub RunGame
EraseBall()
' Calculate the new position for ball
BallX = BallX + StepX
BallY = BallY + StepY
' Hit right wall
If BallX >= RightWallX Then
StepX = -StepSizeX
EndIf
' Hit left wall
If BallX <= LeftWallX Then
StepX = StepSizeX
EndIf
' Hit bottom wall
If BallY >= BottomWallY Then
StepY = -StepSizeY
EndIf
' Hit top wall
If BallY <= TopWallY Then
StepY = StepSizeY
25
EndIf
' Hit right paddle
If (BallX >= RightPaddleX-12) And (BallY >= RightPaddleY) And
(BallY <= RightPaddleY+60) Then
StepX = -StepSizeX
DrawRightPaddle()
EndIf
' Hit left paddle
If (BallX <= LeftPaddleX+12) And (BallY >= LeftPaddleY) And
(BallY <= LeftPaddleY+60) Then
StepX = StepSizeX
DrawLeftPaddle()
EndIf
DrawBall()
EndSub
Version 7:
Finally, in V7, we added additional code to count scores and see who is the winner.
GraphicsWindow.FillRectangle(RightPaddleX,RightPaddleY,10,60)
EndSub
' draw ball
Sub DrawBall
GraphicsWindow.BrushColor = "black"
GraphicsWindow.FillEllipse(BallX,BallY,10,10)
EndSub
' erase ball
Sub EraseBall
GraphicsWindow.PenWidth = "2"
GraphicsWindow.BrushColor = "white"
GraphicsWindow.FillEllipse(BallX,BallY,10,10)
GraphicsWindow.PenColor = "white"
GraphicsWindow.DrawEllipse(BallX,BallY,10,10)
EndSub
'' hooking up events
Timer.Interval = 1
Timer.Tick = RunGame
GraphicsWindow.KeyUp = OnKeyUp
' handle key press, move paddles
Sub OnKeyUp
LastKey = GraphicsWindow.LastKey
' GraphicsWindow.Title = "'" + LastKey + "' pressed"
If (LastKey = "W") And (LeftPaddleY >= 31) Then
EraseLeftPaddle()
LeftPaddleY = LeftPaddleY - 10
DrawLeftPaddle()
ElseIf (LastKey = "S") And (LeftPaddleY <= 400) Then
EraseLeftPaddle()
LeftPaddleY = LeftPaddleY + 10
DrawLeftPaddle()
EndIf
If (LastKey = "Up") And (RightPaddleY >= 31) Then
EraseRightPaddle()
RightPaddleY = RightPaddleY - 10
DrawRightPaddle()
ElseIf (LastKey = "Down") And (RightPaddleY <= 400) Then
28
EraseRightPaddle()
RightPaddleY = RightPaddleY + 10
DrawRightPaddle()
EndIf
EndSub
StepSizeX = 2
StepSizeY = 2
StepX = StepSizeX
StepY = StepSizeY
' initial ball position
Sub SetBallToMiddle
BallX=345
BallY=245
EndSub
' Edges of the 4 walls
LeftWallX = 27
RightWallX = 660
TopWallY = 27
BottomWallY = 460
SetBallToMiddle()
DrawBall()
DrawLeftPaddle()
DrawRightPaddle()
GraphicsWindow.Title = "Pong"
' begin scores
leftscore = Controls.AddTextBox(5,1)
rightscore = Controls.AddTextBox(531,1)
mesgboard = Controls.AddTextBox(265,1)
leftscorecount = 0
rightscorecount = 0
Controls.SetTextBoxText(leftscore, leftscorecount)
Controls.SetTextBoxText(rightscore, rightscorecount)
29
Sub RunGame
EraseBall()
' Calculate the new position for ball
BallX = BallX + StepX
BallY = BallY + StepY
' Hit right wall
If BallX >= RightWallX Then
StepX = -StepSizeX
EndIf
' Hit left wall
If BallX <= LeftWallX Then
StepX = StepSizeX
EndIf
' Hit bottom wall
If BallY >= BottomWallY Then
StepY = -StepSizeY
EndIf
' Hit top wall
If BallY <= TopWallY Then
StepY = StepSizeY
EndIf
' Hit right paddle
If (BallX >= RightPaddleX-12) And (BallY >= RightPaddleY) And
(BallY <= RightPaddleY+60) Then
StepX = -StepSizeX
DrawRightPaddle()
EndIf
' Hit left paddle
If (BallX <= LeftPaddleX+12) And (BallY >= LeftPaddleY) And
(BallY <= LeftPaddleY+60) Then
StepX = StepSizeX
DrawLeftPaddle()
EndIf
' Hit right goal
30
If (BallX >= RightWallX) And (BallY > 200) And (BallY < 300)
Then
SetBallToMiddle()
DrawBall()
GraphicsWindow.Title = "Left player scored"
leftscorecount = leftscorecount + 1
Controls.SetTextBoxText(leftscore, leftscorecount)
EndIf
' Hit left goal
If (BallX <= LeftWallX) And (BallY > 200) And (BallY < 300) Then
SetBallToMiddle()
DrawBall()
GraphicsWindow.Title = "Right player scored"
rightscorecount = rightscorecount + 1
Controls.SetTextBoxText(rightscore, rightscorecount)
EndIf
DrawBall()
' check who won
If leftscorecount >= 3 Then
Controls.SetTextBoxText(mesgboard, "Left side WON!!!")
TheEnd()
EndIf
If rightscorecount >= 3 Then
Controls.SetTextBoxText(mesgboard, "Right side WON!!!")
TheEnd()
EndIf
EndSub
' End the game
Sub TheEnd
SetBallToMiddle()
StepSizeX = 0
StepSizeY = 0
EndSub
31
We did all this in about 2 hours, on and off. You know kids
attention span is short :)
Ray FAST
7 Jan 2013 1:10 PM
32
The single most important concept in programming is loop, I think. And yet, it's (usually) not an easy concept for kids to
grasp. I remember when I was young, I had to struggle with the idea of loop and N=N+1.
Back then, a loop in BASIC might look like this:
10 PRINT "123"
20 GOTO 10
GOTO statement had and continues to have the reputation of producing spaghetti code. However, based on my
estimation, it does make it much easier to explain the loop :)
Of course, the two-line code above will go into infinite loop and the only way to stop it is by forcing stop execution of
the program, e.g., by hitting Ctrl-C.
So, how to make 10 loops? Here is one way to do it.
10
20
40
30
50
N=1
PRINT N
IF N>=10 THEN END
N=N+1
GOTO 20
Another way is to use the FOR-NEXT construct. I think it goes something like this:
10 FOR I = 1 TO 10
20 PRINT I
30 NEXT I
33
For i = 1 To 10
TextWindow.WriteLine(i)
EndFor
Here is the output:
1
2
3
4
5
6
7
8
9
10
Press any key to continue...
In most programming language, white spaces (hence indentation) is insignificant (with Python being a notable
exception)
Therefore, for good programming practice, it's important to indent text appropriately.
For example, with the TextWindow.WriteLine(i) being indented here, it is much easier to see that it's a FOR block.
That being said, it's still not a walk in the park to explain this to my son.
You would be surprised at how kids learn things. They learn things they want to learn, the way they want, when they
want!
I spent about 20 minutes each on two different occassions explaining loop to him. I thought he got it. He appeared to
understand it. But when asked a day later, he is like "I don't know."
It stayed this way until over the holiday weeks when he finally got it. It was so intersting how it happened that I simply
have to share it.
He was playing Minecraft (one of his favorite games for now), and was very excited to explain to me how he figured out
a way to "trick" the game.
34
Since I don't play Minecraft, I am not sure if I can explain this well, but will try. For some reason, he needed to change
the time in the game (turning from night to day, or vice versa) by activating a switch or something like that.
The idea he came up with was to construct a circular track and then made the truck to go around and around. Every time
it gets to a specific spot on the track, something will be triggered which will then change the time and what not.
Upon hearing this, I seized the opportunity to explain to him that is in fact a LOOP, an infinite loop that is.
The circular track is the loop itself. The action that's triggered each time the truck go through a specific spot is the
content within the loop.
He thought about it and exclaimed he got it. I do think he really got it this time :)
So the moral of the story is that one doesn't have to sit in front of Visual Studio (or Kid Studio) all day long to learn
programming. Learning happens all the time and in mysterious ways, and especially so for little kids.
Lastly, here is something for a little fun:
For i = 1 To 100000
TextWindow.Write("123")
EndFor
35
For i = 1 To 100000
TextWindow.Write("1234")
EndFor
Can you see why printing "123" and "1234" produce different effects on your eyes?
Here is a hint.
Usually, the width of the text console is an even number. The length of "123" string is an odd number.
Ray FAST
3 Dec 2012 2:04 PM
6
36
Its always fun to teach the little ones to learn and do something.
Teaching programming is no different. As previously mentioned, I have been on the lookout for a fun and low-barrier
language for beginners, a third grader to be exact.
So far, all in all, Ive spent about 20-30 hours with my son on getting used to the idea of Small Basic.
He is proficiently familiar with operating a computer, playing some games, including MineCraft (yeah, its Java based I
know. Trying to explain heap size to him was no fun)
Anyway, we were on vacation recently and he got really bored with swimming and sand digging, and decided to write a
game himself. So, thats what we have here.
I had to explain the concept of array to him, and didn't exactly remember how I learned array when I was a kid or how
others normally do. So, after struggling for like five minutes, I finally came up with the analogy of showing him a picture
of a string bean.
The string bean itself is an array, and all the beans inside are the element. Truth be told, I am not sure the analogy really
helped. But between the picture and my three or four attempts are explaining this, he finally got it. Not completely, but
enough to get going.
After that, he pretty much did all that by himself I think in less than one hour while my wife and I were dozing off. Too
much sun does make you sleepy :)
For those of you just started to learn programming and MS Small Basic in particular, I will run through the code briefly,
since there wasnt much (any!) comments in the code.
The last program he wrote (which I will get to in the next installment of the series), he had a lot of comments more
than I see for some programmers code.
But this time around, he was in a big hurry to get the game working, and told me he would add the comments later
when he is done. Of course, the vacation was over, his interest (for the moment) moved onto something else. And we
left with a piece of code with no comment whatsoever. Sounds familiar, no? On the bright side, I am sure he is not
doing it for job security :)
37
GraphicsWindow.Width = 500
GraphicsWindow.Height = 400
The next three lines set up three controls: 2 Text Boxes and 1 Button. Dont overlook those three lines. There are
actually a lot to it.
tbShow = Controls.AddTextBox(170,110)
tbType = Controls.AddTextBox(170,200)
bNext = Controls.AddButton("next",350,200)
Variable name convention. In the past I showed him how to prefix all TextBox controls with tb. I dont think he
quite understand the concept of camel case, but somehow he stuck with the tb convention. Thats the thing
with kids. Sometimes they are willing to do/try things without fully understanding/accepting the rationale
behind it. Further, he improvised by using b for button. I personally use btn (dropping the vowel). He must
have decided that the proper way to do it is to use the first letter of the control. Interesting.
Lack of Label control. Of course, if one graduates to full VB (Visual Basic), the full array of controls (including
Label) will be available. So, he has to make do with Text Box instead.
Positioning of the controls. This he told me he had to try a few times until he felt he got it right.
letter[1] = "a"
letter[2] = "b"
letter[26] = "z"
38
I am still waiting for a proper moment to tell him about the character function, or Text.GetCharacterCode and
Text.GetCharacter functions in the case of SB, and ASCII code, and all that.
But if you are in a hurry, you can give it a try yourself.
These two lines of code will give you the idea of getting the ASCII code for a letter, and displaying a letter (character)
based on the ASCII code.
TextWindow.WriteLine("ASCII
code for 'a' is: " + Text.GetCharacterCode("a"))
TextWindow.WriteLine(Text.GetCharacter(97))
a = "0"
b = "0"
This alarms me. I am not entirely sure where he picked up the bad habit of using one letter meaningless variable
names. I dont think its from me :)
I am going to do more observations on this, to partially fulfill my quest to understand whether a bad programmer was
born that way, or taught that way
Regardless, he decided that one of the variable is used to keep track (counts) of the 10 questions, while the other one is
used to track the correctly typed ones.
n = Math.GetRandomNumber(26)
39
The next line display the letter in the textbox, by setting the display text for that textbox.
Note the reference to the array element letter[n].
Controls.SetTextBoxText(tbShow,letter[n])
The next line associated the subroutine subButtonClicked with the button click event handling.
Controls.ButtonClicked = subButtonClicked
It is a bit different from the usual way of doing it in that the event handling is at button clicked level. Then within the
subroutine subButtonClicked, its further checked which button is clicked by
btnClicked = Controls.LastClickedButton
So, hopefully, now you get the idea of the flow of the program. I will probably have done it differently to make code
tighter. But I guess its good enough for a little kid :)
I will leave the rest of the code for you read through at your own place. Please feel free to comment here if you have any
questions.
40
GraphicsWindow.Width = 500
GraphicsWindow.Height = 400
tbShow = Controls.AddTextBox(170,110)
tbType = Controls.AddTextBox(170,200)
bNext = Controls.AddButton("next",350,200)
letter[1] = "a"
letter[2] = "b"
letter[3] = "c"
letter[4] = "d"
letter[5] = "e"
letter[6] = "f"
letter[7] = "g"
letter[8] = "h"
letter[9] = "i"
letter[10] = "j"
letter[11] = "k"
letter[12] = "l"
letter[13] = "m"
letter[14] = "n"
41
letter[15] = "o"
letter[16] = "p"
letter[17] = "q"
letter[18] = "r"
letter[19] = "s"
letter[20] = "t"
letter[21] = "u"
letter[22] = "v"
letter[23] = "w"
letter[24] = "x"
letter[25] = "y"
letter[26] = "z"
a = "0"
b = "0"
n = Math.GetRandomNumber(26)
Controls.SetTextBoxText(tbShow,letter[n])
Controls.ButtonClicked = subButtonClicked
Sub subButtonClicked
btnClicked = Controls.LastClickedButton
42
Controls.HideControl(tbShow)
Controls.HideControl(tbType)
Controls.HideControl(bNext)
scoredisplay = Controls.AddTextBox(170,160)
score = Controls.AddTextBox(170,200)
Controls.SetTextBoxText(scoredisplay,"
score \/")
43
\/
brestart = Controls.AddButton("restart",310,300)
EndIf
If (brestart = Controls.LastClickedButton) Then
a = 0
b = 0
Controls.HideControl(scoredisplay)
Controls.HideControl(score)
Controls.HideControl(brestart)
Controls.ShowControl(tbShow)
Controls.ShowControl(tbType)
Controls.ShowControl(bNext)
n = Math.GetRandomNumber(26)
Controls.SetTextBoxText(tbShow,letter[n])
EndIf
EndSub
44
Small Basic for Little Kids, Ray FAST, 3K+
36
UPDATED 6/13/13: Added Timo So's MoreOptions Extension. On 5/31/13: Added NaochanOn's Barcode Extension.
45
o
o
The greatest extension Small Basic has ever seen has finally returned!
The 1.0.387 release can be considered as am unstable development version. NetworkServer and NetworkClient aren't
included this version.
Update doesn't work and some new features have been included.
Step 1: Download
Step 2: Install
Step 3: Test
Step 4: Send feedback
46
Home > Freeware > Microsoft Small Basic - Simple Programming For Kids
WEBSITE: http://smallbasic.com/
For any child that has an avid interest in computers, one of the most magical experiences is when they write their first
program. Microsoft seeks to introduce that amazing experience to students as well as adults with an impressive new
programming tutoring tool called Small Basic.
Small Basic is essentially a "small" version of Microsoft's well known programming language called Visual Basic. Visual
Basic itself is anything but basic, so by offering Small Basic, Microsoft can make inroads with younger students. Small
Basic may be a training tool, but it is a powerful enough programming tool so that some users have even created highly
functional and intricate games such as board games or even simulations.
However, the real value of this software comes from its use in the classroom or in a home-school setting, where each
lesson is laid out by Microsoft in a series of instructional lessons followed by exercises where the student can put what
they've learned into practical use.
47
When the student first download and installs the Small Basic application, it isn't really obvious how the software works.
There is no instruction set or directory provided where students can just choose from available commands and functions.
Instead, the student must actually work through the lessons and learn each of the functions individually. While this is
more time consuming than a more visual tool may be, this lesson-based approach may actually provide better retention
of that information.
48
The most impressive thing about Small Basic isn't so much the application itself, but the fact that Microsoft put so much
effort into coming up with a high-quality curriculum that consists of dozens of lessons. You can find each lesson under
the "Small Basic Curriculum" header in the right navigational bar on the Small Basic website. Ideally, students should
work through the lessons, starting from Lesson 1.1 and moving forward.
Slideshow Lessons
Each of the lessons are created as a PowerPoint slideshow presentation, so it's a given that teachers or parents will
need PowerPoint available in order to work through each lesson with students. The PowerPoint lessons consist of
animated slides that work through explanations of each set of instructions. Every lesson builds upon what the student
has already learned in past lessons.
49
A Lesson Slide
Each slide is well designed by Microsoft, and obviously developed by someone with a good understanding of how
students learn. The animated nature of each slide will hold the students interest, as actual snippets of code are
displayed and the different elements of the sample program are pointed out.
After each lesson, students can then go back to the Small Basic programming environment and put what they've learned
into practice. Once they start typing the commands they've learned, helpful tips will pop up on the right side of the
screen, showing the student additional information about the function and the many different properties and settings they
can use.
50
Autotext
You can even see elements of other Microsoft products appear throughout the Small Basic application. For example, all
the student has to do is type a letter, and the program will provide a pop-up box of suggestions of words that the student
is probably trying to type. This is particularly useful for when students can't quite remember the full name of a function
they wanted to use. All they have to do is type the first few letters and they'll see the function listed in the pop-up box.
When the student is finished typing their test programs into the Small Basic application, all they have to do is click the
big blue "Run" button in the top menu. Small Basic will switch into "runtime" mode, and the application window will
appear, displaying the textbox or images that the student programmed.
51
Advanced Games
For anyone that thinks Small Basic isn't capable of producing anything of any real value, all you have to do is browse
some of the sample programs from the forums. Students often post the results of some of their work there, and you'll find
everything from simple mathematical programs, to some impressive advanced game environments like tic tac toe or
even a graphical driving simulator. The software is really only limited by the level of creativity and imagination of the
student.
To get to the MSDN code samples gallery, just click on the link to the forums from the main Small Basic web page, and
then click the "code" link at the top of the page. The Code Samples Gallery is filled with plenty of sample programs
students can use as a starting point to learn some of the more advanced programming techniques.
52
After students have worked through all of the lessons and reached a level where the Small Basic programming
environment just doesn't offer the more advanced functionality that students desire, they can make use of Visual Basic
by clicking on the "Graduate" button in the top menu. This button will automatically export the student's existing Small
Basic code into a full Visual Basic format. Students can then continue working on the software in the more advanced
Visual Basic programming environment. Microsoft now offers Visual Basic Express for students that want to learn how to
write VB for the Microsoft Windows environment.
Small Basic is really an excellent free tool that educators can use to bring programming skill into the classroom. The
ability to think and program in a logical way is a skill set that extends well outside of the classroom. It is important for
educators to understand, however, that Small Basic is intended primarily as an environment to learn VB programming.
To that end, Small Basic will not teach C++, Java or other programming languages. However, in learning the basic
structure and terminology of programming, understanding Visual Basic will make it much easier to learn those more
advanced languages down the road.
53