Download presentation
Presentation is loading. Please wait.
Published byCoral Haynes Modified over 9 years ago
1
Visual BasicC++ Diane Zak
2
Microsoft © Small (But Powerful) Basic Presented by Diane Zak
3
1GB Silicone Wrist Band Flash Drive You are welcome to take them home!
4
Overview Walk-throughs Code snippets Activities Wrap-up
5
OVERVIEW
6
What is it? 1. Language 2. IDE 3. Libraries Created by: Vijaye Raji at Microsoft http://smallbasic.com/
7
Language Variables Assignment statements Concatenation, arithmetic, relational, logical operators Mathematical functions Graphics (shapes and controls) If statements, For and While loops Arrays Sequential access file processing Text (string) manipulation methods Sub procedures and events
8
IDEIDE Intellisense Help
9
Libraries ArrayMouse ClockNetwork ControlsProgram DesktopShapes DictionarySound FileStack FlickrText GraphicsWindowTextWindow ImageListTimer MathTurtle
10
1.Language 2. IDE 3. Libraries
11
Requirements? Small Basic Windows XP, Vista, 7.NET Framework 3.5
12
Why would I want to learn it?
13
Fun and easy way to introduce programming Intro to Computers Intro to Programming College Freshmen Day High School Recruitment
14
How can I teach it?
15
Turtle Object TextWindow sequence only or combined with selection
16
TextWindow sequence, selection, repetition, sound, and random numbers
17
GraphicsWindow and Turtle sequence only or combined with selection and repetition
18
GraphicsWindow and Turtle sequence only
19
GraphicsWindow sequence and repetition
20
GraphicsWindow sequence, selection, repetition, random numbers, and counters
22
GraphicsWindow sequence, selection, arrays, controls, and procedures
23
GraphicsWindow sequence, selection, arrays, controls, and procedures
26
Walk-throughs
27
TextWindow
38
On your own: 1.Enter a TextWindow.Write statement that displays the message “Gallons: ” 2.Enter a TextWindow.ReadNumber statement that assigns the user’s input to the gallons variable
40
Arithmetic operations +addition (also can be used for concatenation) –subtraction *multiplication /division Math.Powerexponentiation Math.Floorinteger division
41
mpg = miles / gallons
42
TextWindow.WriteLine(mpg)
45
Math object’s Round method mpg = Math.Round(mpg)
46
String concatenation operator + "Miles per gallon: " + mpg
50
Publish
53
Import
55
If Statement If condition Then statements [ElseIf condition Then statements] [Else statements] EndIf
56
If mpg > 30 Then TextWindow.WriteLine("Great") Else TextWindow.WriteLine("Not great") EndIf
57
Save using Mpg and then run. Then publish again.
59
Graduate to Visual Basic
60
Turtle
61
1.Close the mpg program. 2.Open a new document. 3.Save the new document as MyFirstTurtle.
62
1.Create a 10 line program using the following commands. Keep in mind that the default height and width of the GraphicsWindow is 442 and 624 pixels, respectively. 2.Save and then run. Turtle.Speed = number from 1 through 10 Turtle.Move(number of pixels) Turtle.MoveTo(x, y) Turtle.TurnLeft() Turtle.TurnRight()
63
1.Close the MyFirstTurtle program. 2.Open the Hi.sb file contained in the Class folder. 3.Run the program.
65
1. ' Lines 2 through 8 will center the GraphicsWindow 2. GraphicsWindow.Hide() 3. gwH = 400 4. gwW = 225 5. GraphicsWindow.Left = (Desktop.Width - gwW) / 2 6. GraphicsWindow.Top = (Desktop.Height - gwH) / 2 7. GraphicsWindow.Height = gwH 8. GraphicsWindow.Width = gwW 10. ' Line 11 displays text on the title bar 11. GraphicsWindow.Title = "Hi" 13. ' Line 14 shows the GraphicsWindow 14. GraphicsWindow.Show() 16. ' Line 17 sets the Turtle's speed 17. Turtle.Speed= 9 19. ' position turtle and draw left vertical line in H 20. Turtle.X = 50 21. Turtle.Y = 350 22. Turtle.Move(250)
66
24. ' reposition turtle and draw right vertical line in H 25. Turtle.PenUp() 26. Turtle.X = 100 27. Turtle.Angle = 180 28. Turtle.PenDown() 29. Turtle.Move(250)
67
31. ' reposition turtle and draw horizontal line in H 32. Turtle.PenUp() 33. Turtle.Y = 200 34. Turtle.TurnRight() 35. Turtle.PenDown() 36. Turtle.Move(50)
68
38. ' reposition turtle and draw vertical line in i 39. 40. 41. 42. 43. 44.
69
38. ' reposition turtle and draw vertical line in i 39. Turtle.PenUp() 40. Turtle.X = 150 41. Turtle.Y = 350 42. Turtle.TurnRight() 43. Turtle.PenDown() 44. Turtle.Move(200) Answer
70
Drawing Shapes 46. ' draw circle above vertical line in i 47. <use the GraphicsWindow’s DrawEllipse method (Hint: use 145 and 100 for X and Y, and use 10 for the width and height>
71
Drawing Shapes 46. ' draw circle above vertical line in i 47. GraphicsWindow.DrawEllipse(145, 100, 10, 10) Answer
72
1.Complete Lines 49 through 65. 2.Save and then run.
73
Images and Sound
74
1.Close the Hi program. 2.Open the PicViewer.sb file contained in the Class folder. 3.Run the program to see the effect of the existing code.
75
13. ' Lines 14 through 16 load the images and assign names to each 14. imgBirds = ImageList.LoadImage(Program.Directory + "\birds.jpg") 15. imgCat = ImageList.LoadImage(Program.Directory + "\cat.jpg") 16. imgTheEnd = ImageList.LoadImage(Program.Directory + "\TheEnd.jpg") 18. ' Lines 20 through 22 make each loaded image a Shape object that can 19. ' be moved, animated, shown, hidden, or rotated 20. birds = Shapes.AddImage(imgBirds) 21. cat = Shapes.AddImage(imgCat) 22. theEnd = Shapes.AddImage(imgTheEnd)
76
24. ' Lines 25 through 27 position each Shape object at the right edge of the GraphicsWindow 25. Shapes.Move(birds, 650, 0) 26. Shapes.Move(cat, 650, 0) 27. Shapes.Move(theEnd,650, 0) 29. ' Lines 31 through 33 hide each Shape object (this is necessary because the 30. ' AddImage method automatically displays them on the GraphicsWindow 31. Shapes.HideShape(birds) 32. Shapes.HideShape(cat) 33. Shapes.HideShape(theEnd) 35. ' Line 36 shows the GraphicsWindow 36. GraphicsWindow.Show()
77
38. ' enter the code to play a wav file named PicViewer.wav 39. <Use the Sound object’s Play method, the Program object’s Directory method, and the concatenation operator to play the "\PicViewer.wav" file.>
78
38. ' enter the code to play a wav file named PicViewer.wav 39. Sound.Play(Program.Directory + "\PicViewer.wav") Answer
79
41. ' Lines 42 through 44 show the birds Shape object, animate it, and then delay the program 42. Shapes.ShowShape(birds) 43. Shapes.Animate(birds, -500, 0, 6000) 44. Program.Delay(4000)
80
1.Complete Lines 46 through 54. 2.Save and then run. 3.For an additional challenge, complete the DIFFERENT VERSION section.
81
Events and Sub Procedures
82
1.Close the PicViewer program. 2.Open a new document. 3.Save the new document as Hello.
83
1. Enter the following two lines of code: txtName = Controls.AddTextBox(100, 50) btnHello = Controls.AddButton("Hello", 100, 100) 2. Save and then run.
84
1. Enter Controls followed by a period. 2. Press the down arrow until the ButtonClicked event is selected.
85
Finish the statement as follows: Controls.ButtonClicked = OnButtonClick
86
Now we need to create the OnButtonClick event procedure. Enter the following lines of code: 5. Sub OnButtonClick 6. myName = Controls.GetTextBoxText(txtName) 7. GraphicsWindow.ShowMessage(myName, "Name Entry") 8. EndSub
87
1.Save and then run. 2.Click the text box and then type your name. 3.Click the Hello button.
89
Activities Now it’s time for you to have some fun!
90
Take your pick: 1.Create the Space Invaders game using the handout provided to you. 2.Look in the EXE folder on your flash drive for a program you might like to create. Then, locate the partially completed.sb file on your flash drive. The FolderContents.doc file on your flash drive provides some additional information about the program. 3.Create your own Small Basic program. 4.Check out the Coin Toss.sb program in the Coin Toss folder. 5.Import one or more of the following programs/games: XHX455 (Click Shapes)KXM316-0 (Calculator) CBX615 (Flower)LWL206-3 (Music Notes) MDJ923 (Paddle Game)PMT149 (Bouncing Balls)
91
Thank you for coming!
92
I hope you enjoyed the presentation
93
Have a great day!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.