Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
TextWindow Object
Page 1
Windows Development
Sign in
Aspiring Professional
4. TextWindow Object
Chapter 1:
Introducing
Small Basic
Chapter 2:
Overview of
Small Basic
Programmin
g
Chapter 3:
Program
Object
Chapter 4:
TextWindow
Object
Chapter 5:
GraphicsWin
dow Object
4. TextWindow
Object
Preview
TextWindow Object
The TextWindow is an object
where we can receive text input
and write text output. In Small
Basic, text windows are usually
used for simple programs with no
graphic elements. We used the
text window in the examples in
Chapter 3.
TextWindow Properties:
BackgroundColor
Gets or sets the background
color of the text to be output in
the text window.
This chapter is
adapted from the
book The Developers
Reference Guide To
Microsoft Small Basic
by Philip Conrod and
Lou Tylee.
To purchase this book
in its entirety, please
see the Computer
Science For Kids web
site.
CursorLeft
Gets or sets the cursor's column
position in the text window.
CursorTop
Gets or sets the cursor's row
position in the text window.
ForegroundColor
Gets or sets the foreground color
of the text to be output in the
text window.
Left
Gets or sets the left position of text window on your
computer screen.
Title
Gets or sets the title for the text window.
Top
Gets or sets the top position of text window on your
computer screen.
TextWindowMethods:
http://msdn.microsoft.com/hr-ba/beginner/hh182552(en-us).aspx
15.9.2014 12:22:31
4. TextWindow Object
Page 2
Clear()
Clears the text window.
Hide()
Hides the text window.
Pause()
Waits for user input before returning.
PauseIfVisible()
Waits for user input only when the text window is open.
PauseWithoutMessage()
Waits for user input before returning (but there is no Press
Any Key message).
Read()
Reads a line of text from the text window. This method will
not return until the user presses Enter. Returns entered
text.
ReadKey()
Reads a key press from the text window. Returns the
pressed key.
ReadNumber()
Reads a number from the text window. This method will not
return until the user presses Enter. Returns entered
number.
Show()
Shows the text window.
Write(data)
Writes text or number (data) to the text window. Unlike
WriteLine, this will not append a new line character, which
means, anything written to the text window after this call
will be on the same line.
WriteLine(data)
Writes text or number (data) to the text window. A new line
character will be appended to the output, so that the next
time something is written to the text window, it will go in a
new line.
TextWindow Features
By default, the text window displays white text on a black
background:
http://msdn.microsoft.com/hr-ba/beginner/hh182552(en-us).aspx
15.9.2014 12:22:31
4. TextWindow Object
Page 3
http://msdn.microsoft.com/hr-ba/beginner/hh182552(en-us).aspx
15.9.2014 12:22:31
4. TextWindow Object
Page 4
TextWindow Input
There are three methods used to get user input in the text
window. The Read method is used to obtain text
information. The <Enter> key is pressed to complete the
input. Similarly, the ReadNumber method is used to obtain
numeric information. With ReadNumber, non-numeric
keystrokes are ignored. Lastly, the ReadKey method
obtains individual keystrokes with no need to press
<Enter>.
http://msdn.microsoft.com/hr-ba/beginner/hh182552(en-us).aspx
15.9.2014 12:22:31
4. TextWindow Object
Page 5
You see the line I input and the line written back out with
WriteLine. The program is now waiting for a numeric
input. Type such an input and press <Enter>. You will only
be able to type numeric characters (0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
single decimal point, single negative sign to start input). Try
non-numeric characters they wont appear. Heres what I
have now (my input and its written value):
TextWindow Output
There are two methods used to write information in the text
window. We have used the WriteLine method. It writes
the information to the window and appends a new line
character. Any subsequent output methods start on a new
line. WriteLine can also be used to write a blank line using:
TextWindow.WriteLine("")
http://msdn.microsoft.com/hr-ba/beginner/hh182552(en-us).aspx
15.9.2014 12:22:31
4. TextWindow Object
Page 6
http://msdn.microsoft.com/hr-ba/beginner/hh182552(en-us).aspx
15.9.2014 12:22:31
4. TextWindow Object
Page 7
Chapter Review
After completing this chapter, you should understand:
Use of the TextWindow object.
Setting TextWindow properties.
Difference between Read, ReadNumber and ReadKey
methods.
Difference between WriteLine and Write methods.
The TextWindow object can only accept and output text
information. Next, we look at the GraphicsWindow object
which allows graphical elements.
Next Chapter > >
| Trademarks | Privacy
http://msdn.microsoft.com/hr-ba/beginner/hh182552(en-us).aspx
15.9.2014 12:22:31