Saturday, October 31, 2009

X and Y

first impression,
x and y..
Something to do wit
add math? or..

No, its vb.
i am gonna talk about it in vb.
if x = y,
those it means y = x?
duh, mathematically yes, its true.
wait, hold your horses.., dun be to sure yet.
remember, i am talking about it in vb.
so, its false..

In vb(visual Basic), it reads the code Line by Line..,
from Left to Right..
always keep these in mind..

x = y
Means that x takes its value from y.
But its doesn't mean y takes its value from x.

vice-versa, for y = x.
means y takes its value from x.
But x does not takes its value from y.

need an example?
here it is:

Label1.caption = TextBox1.Text
From this above, label1 takes the value from TextBox1.
If lets say, you leave TextBox1 blank, and you run the code(
Label1.caption = TextBox1.Text) but you fill up Label1 wit the "Hello".
After you run the code, the word "Hello" will disappear(erase).
Why did it turn out blank?
Some of you may think that why didn't textBox1 display the word "Hello".
Here is the explanation:
1)Remember, blank or nothing is still a value.
2)TextBox1 is blank.
3)Code is read(execute) from left to right.
4)The code(Label1.caption = TextBox1.Text) is executed.
3)Label1 takes its value from textbox1 to replace its current value.
4) Therefore, Label1 becomes blank.

If you were to fill up textBox1 wit the word "Hello" and run the same code,
your label1 will display the word "Hello"

thats all..
try these examples..
and you will understand.

busy man talking..

Tuesday, October 27, 2009

Procedure vb

as you know about functions as i had explain previously.
in programing, object oriented programing.
it consists of function and procedure.
what is the difference u may ask?
in function its like: "Sum(a,b)"
bt in procedure u call it: "call Space"
well, procedure may not need any input at all.

For example:

Private Sub Form_Activate()
Dim space As Single
Dim i As Single
space = InputBox("Line spacing")

For i = 1 To space
Print 'space each line
Next i
Call line1
End Sub

Private Sub line1()
Print "-----------------------------------------------------------"
End Sub

In this above, it will skip the number of lines key in "Space".
it doesn't has input for the procedure, "Call line1"

Here is another example,
bt for this procedure there are input:

Private Sub Form_Activate()
Dim n As Integer
Dim a As String

a = InputBox("name")
n = InputBox("age")

Call Name1(a, n)

End Sub

Private Sub Name1(a As String, n As Integer)
Print "My name is " & a & " and i am at the age of " & n

End Sub

Basically, this one has a procedure that collects the input n and a.
Then print it.

Next example is an example of using both type of procedure:

Private Sub Form_Activate()
Dim n As Integer
Dim s As Single

s = InputBox("Price per unit")
n = InputBox("Number of units")

Call Header

Call Sum(s, n)
End Sub

Private Sub Header()
Print "The total price is RM";
End Sub

Private Sub Sum(s As Single, n As Integer)
Dim sum1 As Integer

sum1 = n * s
sum1 = Format(sum1, "currency")
Print sum1

End Sub

Well, it jz calculates the price.
thats all.
The format(sum1, "currency")
is to make it in money. xx.xx

thats all.
miss me? i had not update in a long time.
hahax.. i guess not.

Tuesday, October 20, 2009

Functions in vb.

What is function? some of you may ask.
a function may be a formula/converter.
it requires input or object(in add math functions).
but in programing we called those parameters.(input)
then it comes out with an output. called image in add math function.
get the picture?

why do we need functions in programing?
here is an example:
this is an quadratic formula:
x = (-b±(b^2-(4*a*c))^(1/2))/(2*a)
So,ur input will be a, b and c.
Which has the output of x.
If you are creating a program which may use this formula a lot of times.
dun tell me you are gonna retype it?
even if you copy and paste, it will end up look like a mess.
u can predefine it as a function.
type the code below:

Private Function Quad(a as single, b as single, c as single) as single
Quad = (-b±(b^2-(4*a*c))^(1/2))/(2*a)
End function

So, whenever you want to use it in the same form:
you just have to type

x = Quad(a,b,c)

you just have to fill up the a,b,c.
or get their value from somewhere you wan.
its better if u use a modular and predefine the functions in it.
so, all your forms can use it=)
This is just a simple example.
bare that in mind.
i had made a very complicated function before.
if you are creative enough, you can do a function within a function.
thats not something stupid.
its just ethical.
it will make your program more structural and neat.
it also allows you to easily debug your program.
thats all today.
i had weird dreams lately.
i dream 3 times that i was doing spm add math on the next day.
Are those what they called as signs?
busy man talking.

Sunday, October 11, 2009


yo, its about vb.

teach how to generate a random number

Private Sub Form_Activate()
Dim x, high, low As Integer

'high is the highest limit and low the lowest limit.

high = 999
low = 100

Randomize 'to generate random value each time

x = Int(low+(high-low+1)*Rnd)

Print x
End sub

thats bout it.
the formula its actually a math's formula to make sure the number generated is within the range u want.
The important part is the "Randomize" and "*Rnd"

People like kill_me or c.k yeo will understand in jz a few seconds.
i dunno bout blique though.

bt tell you what..
its nt so random after all..
u will notice when u run it a few times.
back to work..

Friday, October 9, 2009

the result

i had been sick lately.
about the competition..
we did not win.
bt at the same time, v did not lose.
coz in this case there is no lost.
v came in empty handed and came out with experience.
V are just people who try. and we will keep on trying.
next year, we will be the ones in front taking the award.
not to say that i/v am/are stubborn.. bt we will not giv up.
after all at least we made it to the finals.
in our category.., we are the only one tat came out with software.
the rest are hardware.. like robotic arms..., advanced optical disc simulator.
yess..., pawn....
its our school first debut.
made our school proud.

when we got there at first.
we were treated as quest not finalist.
mayb coz of the wat i look la.
mun fuong tot that he wore formal but when he got there he notice that everyone else is even more formal.
you should had seen how kok kian look like wearing long sleeve.
its so not a gud way.
The way they announce the result its like the grammy awards.
they will preview the finalist.
many people laugh when they preview ours. coz i name it kai_mun_kok
at least we gt famous somehow.
kok kian met the girl that he like.
and he saw two girls playing rubic cube bt unable to solve it.
i told him to go teach them bt he dun wan.
lolz.. he could hav use that chance.

There ware many hot chicks there.
bt i didn't make a move as i feel that i come here only for a few reason.
u can ask kok kian if u dun belive.
hannah tan was there too.
many guys gave a hu-ha when they saw her.
many other famous people like Chef Wan was there.
we experience high class people life a bit.
very difficult.
cannot say wrong thing.
i need more rest.
still sick.

At the end we realize that there are many creative people in malaysia.
they are pro.
we are jz like a micro pixel in a picture.hahax

Wednesday, October 7, 2009

8th of october

tmr, 8th of october.
it will decide my future.

whatever outcome it will turn out to be,
i will accept it like a man.(running arround screaming like a physco..hahax..jz jk)

could not sleep at nite i guess.

the competition results is tmr..

btw, gud luck to yit kenn and kill_me who joined the manga competition.=)

Friday, October 2, 2009

24th of september

24th september was my birthday.
it was fun as i had a nice dinner at the curve.

I got a cake from my aunty.
A nice key-chain from my cousin brother.
A shaver that works with battery from my brother.
and a pair of ankle weights weighing 2.5kg each.
thats about it i guess.

The first one to wish me was Carlye.
who had wish me one day earlier than my birthday.
thinking that it was 23rd of september.
hw funny was tat.
bt she was somehow the ony from my class to wish me.

ohh ya, and the girl that i like also had wish me at 00:00
hw was tat=)

kk, i receive the same tradition from the n20.
the birthday thingy.
tat was 1 week after my bday.

i am studying hard now.
will blog less.