Hack Forums
[.NET] [TUT] Working With Variables[VB.Net] - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] [TUT] Working With Variables[VB.Net] (/showthread.php?tid=1364743)



[TUT] Working With Variables[VB.Net] - Exodus-:) - Jun 9, 2011

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:



* - H3x0S - Jun 9, 2011

Sorry, but this is a bad tutorial. You haven't explained anything.


* - Exodus-:) - Jun 9, 2011

Come on this was my first thread on this section :(



* - Ethernal Five - Jun 9, 2011

Change the blue color, its really hard to read xD


* - Exodus-:) - Jun 9, 2011

(Jun 9, 2011 10:25 AM)uitklapbare eekhoorn Wrote:  Change the blue color, its really hard to read xD

Thanks for the update already removed the Color :D




* - cOld fus1on - Jun 9, 2011

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


* - Exodus-:) - Jun 9, 2011

(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



* - Grey Mind - Jun 9, 2011

Maybe you can explain a bit more but not bad for first tutorial =]


* - Exodus-:) - Jun 9, 2011

Thanks greymind and i'll be posting other tutorial with more details :)