Download presentation
Presentation is loading. Please wait.
Published byVincent Stevens Modified over 9 years ago
1
Introduction to Computing Dr. Nadeem A Khan
2
Lecture 9
3
Built-in Functions (Contd.) Fixed length string formatting: Fixed length string formatting: ► FunctionString Value Format$(1234567890, “@@@@@@@@@@”)? Format$(123, “@@@@@@@@@@”)? Format$(“1234.56”, “@@@@@@@@@@”)? Format$(“$1,234.56”, “@@@@@@@@@@”)? Format$(1/4, “@@@@@@@@@@”)?
4
Sub Text1_KeyPress(KeyAscii as Integer) statements statements End Sub ► Text1_KeyPress event will occur when Text1 has the focus and a key is pressed Text1 has the focus and a key is pressed The Keypress Event Procedure
5
Sub Text1_KeyPress(KeyAscii as Integer) statements statements End Sub ► Keyascii is a variable (of type Integer) gets the ANSI value of the pressed key value is used to display the corresponding character in the Text1 at the end of this procedure The Keypress Event Procedure (Contd.)
6
The ANSI (ASCII) Code ► A 7 bit code representing one of the 95 characters (including space) ► Normally one byte is used to store this code
7
What will happen in these cases? Sub Text1_KeyPress(KeyAscii as Integer) Let KeyAscii =65 Let KeyAscii =65 End Sub Sub Text1_KeyPress(KeyAscii as Integer) Let KeyAscii =0 Let KeyAscii =0 End Sub The Keypress Event Procedure (Contd.)
8
Generating Random Numbers The function: Rnd The function: Rnd ► Generates a random number from 0 up to but not including 1 Picture1.Print Rnd‘print a different number each time Let numvar= Rnd‘a random value is assigned
9
Generating Random Numbers (Contd.) The function: Rnd The function: Rnd Display numbers from the set {1,2,3,4,5,6} randomly!
10
Generating Random Numbers (Contd.) The statement: Randomize Timer? The statement: Randomize Timer?
11
Generating Random Numbers (Contd.) The statement: Randomize Timer The statement: Randomize Timer Sub Command1_Click ( ) Rem Display a lottery number Picture1.Cls Randomize Timer Picture1.Print Int(10*Rnd); Picture1.Print Int(10*Rnd) End Sub
12
Read Chapter 4 completely
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.