Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[TUT] Working With Variables[VB.Net]

Hello HF!
Today i'm gonna show how to work around with Variables.
First we need to know what a "Variable" is?

Well a Variable or a Set of Variables might be a logic set of Attributes or a symbol that represents a value or a quantity in a Algebric Expression.
The variable UserName, for example,
might have the value Plank, and the variable Discount might have the value 0.65. UserName and
Discount are variable names, and Plank and 0.65 are their values. Plank is a string (that is, text),
and 0.65 is a numeric value. When a variable’s value is a string, it must be enclosed in double
quotes. In your code, you can refer to the value of a variable by the variable’s name.


For this Tutorial, You need: Visual Basic 2010 Express
Little Experience in VB.net


Set of Tools:
* 1 Button (Simple Tutorial as it is :D )


First of all open Vb 2010 and Choose "Windows Forms Application".
Spoiler (Click to View)

Now Select a Button from the ToolBox and add it to the Form.

Now here is the part where the coding starts.
Switch to "Code View" and type

Code
Dim Amount As Decimal

This will declare the "Amount" of your Product as a Decimal

Now add,

Code
Dim Discount As Decimal

Now this will declare your "Discount" as a Decimal too.

Now put,

Code
Dim DiscountedAmount As Decimal

Now we have declared the Discounted Amount as a Decimal

Then we have to put in the values of the Amount and Discount. So,

Amount = 2500
Discount = 0.65
(You can change the Values Accordingly)

Now you must put "D" (Capital D) in-front of the discount value so it's value can be treated as a Decimal, Like:

Code
Discount = 0.65D

Now All the values have been assigned, Now the Discount Calculation Code:

Code
DiscountedAmount = Amount * (1 - Discount)

For N00bs this code is read as,

Code
DiscountedAmount: 2500 * (1 - 0.65)

Then to view the Discount Decimal Value:

Code
MsgBox("Your Discount Amount/Value is $" & DiscountedAmount)

For N00bs, this code will display your calculated DiscountedAmount as a Message Box. So after putting together the whole code it will look like this :
Spoiler (Click to View)

And this ends my Simple and Easy to understand N00b Friendly tutorial in understanding Variables.. :D
Tutorial Written By Me


Note:
Sorry, but this is a bad tutorial. You haven't explained anything.
Come on this was my first thread on this section :(
Change the blue color, its really hard to read xD
(Jun 9, 2011 10:25 AM)Ethernal Five Wrote:  Change the blue color, its really hard to read xD

Thanks for the update already removed the Color :D

I guess this tut is good if someone is wanting to know how to use 'decimal' , but as far as variables as a whole, you need alot more in this tutorial.

But good job with decimal, as your first tut..
(Jun 9, 2011 10:40 AM)cOld fus1on Wrote:  I guess this tut is good if someone is wanting to know how to use 'decimal' , but as far as variables as a whole, you need alot more in this tutorial.

But good job with decimal, as your first tut..

Thank you for your feedback.. and thanks for the Positive Reply :D
Maybe you can explain a bit more but not bad for first tutorial =]
Thanks greymind and i'll be posting other tutorial with more details :)


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Javascript]  by Z3R00NDATOct 16, 2023 01:24 PM 3 134 Oct 16, 2023 01:24 PM
Last Post: Disease
[C] by bhaktefhabo87Oct 11, 2021 07:28 AM 2 185 Oct 11, 2021 07:28 AM
Last Post: Cool_Pro_Grammer
[Python] by simmerMay 28, 2021 05:33 AM 5 202 May 28, 2021 05:33 AM
Last Post: simmer