VB.NET

Moderators: seancampbell
Number of threads: 4022
Number of posts: 10035

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Caculation Posted by ykim87 on 27 Mar 2011 at 1:37 PM
Can anyone show a newbie how this works? I tried doing it myself but I seem to keep getting errors and the book I'm using is not so helpful.

For example, I want to calcuate the gallon of paint (Length + Width) times 2 times 10 feet height and divide it all by 300.

My understanding is you have to start it off by "Dim" correct? Can anyone show me how this works?

Thanks-Young
Report
Re: Caculation Posted by DaiMitnick on 28 Mar 2011 at 9:21 AM
Hi Young, yes this Dim you speak of is the way in which you declare variables. You do Dim <variable name> As <variable type>. You can then assign values to these variables and perform calculations on them. For instance your code would need to be something like (but more added):

Dim intWidth as Integer
Dim intHeight as Integer
Dim intResult as Integer

IntWidth = 50
IntHeight = 100
IntResult = (IntWidth * IntResult) / 2

MsgBox(IntResult)



This would display a message simply saying 2500.
For more on variables take a look at:
http://visualbasic.about.com/od/quicktips/qt/vardeclare.htm
And any other beginner sites for VB.NET

HTH, Dai


------------------------------------------
Do or do not, there is no try. |
------------------------------------------
Report
Re: Caculation Posted by ykim87 on 28 Mar 2011 at 9:38 AM
I tried the int and it kept giving me error, what am I doing wrong?

Thanks-Young
Report
Re: Caculation Posted by DaiMitnick on 28 Mar 2011 at 11:50 AM
Try changing it to double.

D


------------------------------------------
Do or do not, there is no try. |
------------------------------------------



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.