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..

No comments: