Discussing variables in visual basic & c#
· With Visual Basic.net, most of programming languages,what you are doing is storing things in the computer memory. If you want to add two numbers together, you put the numbers into storage areas and "tell" vb to add them up. But you can't do this without variables.
· So a variable is a storage area of the computers memory location in hex value
Now examine this:in vb.net:
Dim a As integer
Dim b As integer
· the above code from Visual Basic Net. It's VB's way of setting up (or declaring) variables.
ORIn c#:
Int a
Int
· Here int means integer type variable Declaration:
· Dim:
Short for Dimension. It's a type of variable. You declare (or "tell" Visual Basic) that you are setting up a variable with this word. We'll meet other types of variables later, but for now just remember to start your variable declarations with Dim
· A, B:
This is a variable. In other words, our storage area. After the Dim word, Visual Basic is looking for the name of your variable. You can call your variable almost anything you like, but there are a few reserved words that VB won't allow. It's good practice to give your variables a name appropriate to what is going in the variable
· As integer:
We're telling Visual Basic that the variable is going to be a number (as integer).We can give alternatives to Integer later.
· A = 3
The equals sign is not actually an equal’s sign. The = sign means assign a value of. In other words, here is where you put something in your variable. We're telling Visual Basic to assign a value of 3 to the variable called A.
No comments:
Post a Comment