Cie AS Computing
Dear all,
Welcome to AS computing class. I am Dr.Ravi your facilitator for this course. This course consists of two modules, theory and practicals. In theory we will have 12 chapters and in practicals we do have programming classes. You will sit for theory and practical exams at the end of the course, which is conducted by CIE.
All the best, keep moving, for there is always a helping hand above you to guide you.
Dr.Ravi
Tags:
Thanks guys, em why some coding doesn't print when we run that program?can anyone tell me,
Question 5 ( Change a small letter to a capital letter)
Dim p As Integer
x = InputBox("Enter a small letter")
p = Asc(x)
Form1.Print Chr$(p - 32): MsgBox "Done": End
This one is surprisingly short... :/
Today's Lesson:
Tracing The Output!!!
Dim a(5) As Integer
10 I = I + 1
b = InputBox("Enter Value")
a(I) = Val(b)
If I = 5 Then GoTo 20
GoTo 10
20 P = 1
BIG = a(P)
30 P = P + 1
If BIG < a(P) Then BIG = a(P)
If P = 5 Then GoTo 40
GoTo 30
40 Print BIG
MsgBox ("Biggest Value")
To Trace the Output, better to make 6 columns in a table as such:
P |
BIG |
a(P) |
If BIG < a(P) |
BIG=a(P) |
Output |
1 |
37 |
a(1) |
|
|
|
2 |
37 |
a(2) |
37<74 True |
74 |
|
3 |
74 |
a(3) |
74<54 False |
74 |
|
4 |
74 |
a(4) |
74<48 False |
74 |
|
5 |
74 |
a(5) |
74<18 False |
74 |
74 |
this makes a clearer view of what the computer is working on, and hopefully we get the right output XD
| ASSIGNMENT | ||||||||
| a(1) | 37 | |||||||
| a(2) | 74 | |||||||
| a(3) | 54 | |||||||
| a(4) | 48 | |||||||
| a(5) | 18 | |||||||
| P | BIG | P= P + 1 | a(P) | IF BIG < a(P) | BIG = a(P) | OUTPUT | ||
| 1 | 37 | 2 | 74 | TRUE | 74 | 74 | ||
| 74 | 3 | 54 | FALSE | 74 | 74 | |||
| 74 | 4 | 48 | FALSE | 74 | 74 | |||
| 74 | 5 | 18 | FALSE | 74 | 74 | |||
| Command | ||||||||
| Dim a(5) As Integer | ||||||||
| 10 i = i + 1 | ||||||||
| b = InputBox("Please enter your number") | ||||||||
| a(i) = Val(b) | ||||||||
| If i = 5 Then GoTo 70 | ||||||||
| GoTo 10 | ||||||||
| 70 p = 1 | ||||||||
| 80 big = a(p) | ||||||||
| 90 p = p + 1 | ||||||||
| If big < a(p) Then big = a(p) | ||||||||
| 98 If p = 5 Then GoTo 110 | ||||||||
| 100 GoTo 90 | ||||||||
| 110 Form1.Print big | ||||||||
| MsgBox big | ||||||||
| Close | ||||||||
| NAME | : RAJ KUMARAN KALIDAS | |||||||
| ID | : 7137 | |||||||
| Assignment | |||||||||
| P | BIG | a(P) | P=P+1 | if BIG < a(P) | BIG = a(P) | Output | a(1) | 37 | |
| 1 | 37 | a(2) | 2 | TRUE | a(2) | 74 | a(2) | 74 | |
| 74 | a(3) | 3 | FALSE | a(2) | 74 | a(3) | 54 | ||
| 74 | a(4) | 4 | FALSE | a(2) | 74 | a(4) | 48 | ||
| 74 | a(5) | 5 | FALSE | a(2) | 74 | a(5) | 18 | ||
| Mujahid Lokman | |||||||||
| 7196 |
|
||||||||
Ok I'll try my best to explain to u guys..
Asc is a code used to change a character(eg. a, B, C, d etc.) into its ACSII code. For example...if u type Form1.print Asc("A") in VB, u will get the result 65, which is the ASCII code of capital A...
Chr$ on the other hand is an inverse form of Asc where it is used to change an ASCII code to a character. For example....typing Form.print(65) in VB will give u the character 'A' as the result.
Therefore in the program that i wrote, i used p=Asc(x), where x is a small letter and hence p will be the ASCII code of the character entered. Then i gave a print statement to print Chr$(p-32) since the 'ASCII code of a capital letter=ASCII code of small letter - 32'.
Since the code Chr$ will change the ASCII code into a character, hence the capital letter of the entered character will be printed out.
Thats bout it. Hope u guys understand what i'm trying to say. :)
Raj Kumaran Kalidas said:
Dain, what is Asc(x) and Chr$(p-32) ?
I have no idea what the $ is for Cho...U have to ask Dr. Ravi bout that....maybe it's something to do with a string variable of some sort :/
Muhammad Mujahid Lokman said:
dain, do we have to put the "$" after the "chr" ? i deleted it and it still works...
© 2025 Created by Ravichandran.
Powered by