Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Calculate volume of a box or rectangular object
Author:
LaVerne Morton
E-mail:
Click to e-mail author
Submitted:
7/14/2009
Version:
VB 2005
Compatibility:
VB 2005, VB 2008
Category:
Mathematics
Views:
13726
This is a program I wrote using a class and a module to measure the volume of a box or rectangular object.
Declarations:
' Written by LaVerne Morton 'Created on July 13, 2009 Module TestSuperBox Sub Main() Dim SuperBox As New SuperBox SuperBox.TestNewDistance() SuperBox.TestBox2() End Sub End Module
Code:
' Written by LaVerne Morton 'Created on July 13, 2009 Public Class SuperBox Public Sub TestNewDistance() Dim FLength As Double Dim ILength As Double Dim FWidth As Double Dim IWidth As Double Dim FHeight As Double Dim IHeight As Double Dim volume As Double Dim totLengthInches As Double Dim totWidthInches As Double Dim totHeightInches As Double Console.WriteLine() Console.WriteLine("The Size and Volume Of This Box") Console.WriteLine() Console.WriteLine("_______________________________________") Console.WriteLine() Console.Write("How many feet in the length of the box ") FLength = Console.ReadLine Console.WriteLine() Console.Write("How many inches in the length of the box ") ILength = Console.ReadLine Console.WriteLine() Console.Write("How many feet in the width of the box ") FWidth = Console.ReadLine Console.WriteLine() Console.Write("How many inches in the width of the box ") IWidth = Console.ReadLine Console.WriteLine() Console.Write("How many feet in the height of the box ") FHeight = Console.ReadLine Console.WriteLine() Console.Write("How many inches in the height of the box ") IHeight = Console.ReadLine Console.WriteLine() Console.WriteLine("Your measurement is: " & FLength & "'" & ILength & """ x " & FWidth & "'" & IWidth & """ x " & FHeight & "'" & IHeight & """") Console.WriteLine() If ILength >= 0 Then totLengthInches = (FLength * 12) + ILength End If If IWidth >= 0 Then totWidthInches = (FWidth * 12) + IWidth End If If IWidth >= 0 Then totHeightInches = (FHeight * 12) + IHeight End If If ILength And IWidth And IHeight > 16 Then Console.WriteLine("************************************************************************") Console.WriteLine("Sorry this box is over 18 inches in length and has to be shipped by UPS.") Console.WriteLine("************************************************************************") End If volume = totLengthInches * totWidthInches * totHeightInches Console.WriteLine() Console.WriteLine("This is the total length of the box in inches : " _ & totLengthInches) Console.WriteLine("This is the total width of the box in inches : " _ & totWidthInches) Console.WriteLine("This is the total height of the box in inches : " _ & totHeightInches) Console.WriteLine() Console.WriteLine("Total volume of the box is: " & volume) Console.WriteLine() End Sub Sub TestBox2() Dim Feet As Integer Dim Inches As Single 'Dim Inches2 As Integer Dim ToInches As Single Dim Centimeters As Single Dim SquareFeet As Single Dim Shaku As Single Dim cost As Double Console.WriteLine() Console.WriteLine(" THE NEW DISTANCE") Console.WriteLine("______________________________________") Console.WriteLine() Console.Write("Please input amount of inches: ") Inches = Console.ReadLine() Console.WriteLine() Console.WriteLine("______________________________________") If Inches <= 0 Then Console.WriteLine("Your number is less than 0") Console.WriteLine() End If Console.WriteLine() Console.WriteLine() If Inches > 0 AndAlso Inches <= 11 Then Inches = Inches Console.WriteLine("Number of inches: " & Inches & " inches.") Console.WriteLine() End If If Inches >= 11 Then Feet += Inches \ 12 Inches = Inches Mod 12 ToInches = Feet * 12 + Inches Centimeters = ToInches * 2.54 SquareFeet = ToInches / 144 Shaku = ToInches * 11.93 Console.WriteLine(" You have " & Feet & " feet and " & Inches & " inches") Console.WriteLine() Console.WriteLine(" It is also written " & Feet & "' " & Inches & """") Console.WriteLine() Console.WriteLine(" Or it is ... " & ToInches & " Total Inches") Console.WriteLine() Console.WriteLine(" Or it is ... " & Centimeters & " Centimeters") Console.WriteLine() Console.WriteLine(" Or it is ... " & SquareFeet & " Square Feet") Console.WriteLine() Console.WriteLine(" Or it is ..." & Shaku & " Shaku(Japanese Measurement For Inch)") Console.WriteLine() Console.WriteLine("The cost for shipping this package is {0:C}", cost) Console.WriteLine() End If End Sub End Class
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement