visual basic

posted by .

here is my source code for my program im trying to convert 10 units from furlong to meters the answer is supposed to be 2011.68 meters
i keep getting 2000. I know if i cant get this right the rest of the conversion will give the wrong answers anybody have any ideas?
Dim inch As Long
Dim fathom As Long
Dim foot As Long
Dim furlong As Long
Dim kilometer As Long
Dim meter As Long
Dim rod As Long
Dim miles As Long
Dim yard As Long
Dim Feet As Long
Dim Original As Long
Dim Desired As Long
Dim A(0 To 9) As Long
Dim B(0 To 9) As Long
Dim result As Long

Private Sub convertButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles convertButton.Click

Feet = Val(ConvertText.Text)
Original = Val(OUnitsTexT.Text)
Desired = Val(DUnitsText.Text)

inch = 0.0833 * Feet
yard = 3 * Feet
meter = 3.28155 * Feet
fathom = 6 * Feet
rod = 16.5 * Feet
furlong = 660 * Feet
kilometer = 3281.5 * Feet
miles = 5280 * Feet

A(1) = inch
A(2) = fathom
A(3) = foot
A(4) = furlong
A(5) = kilometer
A(6) = meter
A(7) = miles
A(8) = rod
A(9) = yard

B(1) = inch
B(2) = fathom
B(3) = Feet
B(4) = furlong
B(5) = kilometer
B(6) = meter
B(7) = miles
B(8) = rod
B(9) = yard

result = ((A(Original)) / ((B(Desired)) / Feet))

lengthText.Text = Val(result)
lengthText.Text = FormatNumber(result, 2, , , TriState.True)

  • visual basic -

    I only know that taking this Conversion Chart, entering 6600 feet and changing to meters, I do get 2022.68.

    This is definitely not my area so I can not help you set up a formula, if that is what you need.


  • visual basic -

    The problem MIGHT be here.

    result = ((A(Original)) / ((B(Desired)) / Feet))

    Some languages (like C and C++) do integer division unless you explicitly make it do "normal" division. In other words, if you do 5/2 in C the result will be the integer 2, not the "floating point number" 2.5.

  • visual basic -

    I just figured it out: It's simpler than that.

    You are declaring all of your numeric variables a LONG. LONG is an integer data type: it does not store anything to the right of a decimal point.

    Try using DOUBLE (or better, DECIMAL, if your version supports it) for any numbers you need to have values to the right of the decimal point.

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions


    PLS, I NEED TO BE GUIDED ON HOW TO WRITE A SIMPLE PROGRAM IN BASIC THAT WOULD PROMPT 3 LEVELS OF AUTHENTICATION WHEN UNAUTHORISED LOG-ON IS EFFECTED. You are not going to be able here to get detailed help on the program code, as there …
  2. visual basic

    Doing a units of measurement program don't know what the formula i need to use to convert the units?
  3. Geometry

    Can you check these multiple choice questions thanks. 1. What is the length of a rectangle that has an area of 20 square meters and a perimeter of 18 meters. A. 10 meters B. 2 meters C. 5 meters D. 9 meters Answer: B 2. Find the minimum …
  4. physics

    You are standing 7.0 meters from a sound source that radiates equally in all directions, but it is too loud for you. How far away from the source should you stand to experience one third the intensity that you did at 7.0 meters?
  5. Programming

    Here is the question that I need help to write the code for the following program in Visual Basic 2010. I am trying to write the code but it has a run time error. If your could helps me to write the code it would be greatly appreciated. …
  6. C++ program

    Please help am not very good at c program. Am supposed to create a source code that will display to the screen the first 20 numbers with their squares and cubes.
  7. Physics

    PLEASE HELP, I'm trying to study for a quiz >.< and I don't understand this one question! A fellow student reports his measurements of time for a speed calculation in minutes. How could he express that calculation using SI base …
  8. Programming (Visual Basic)

    Im seem to be having trouble with this Exercise. Would you mind helping me please?
  9. Chemistry

    K1 = 0.727 K2 = 12.1 T1 = 2000 T2 = 3000 Solve for the standard enthalpy of formation. They gave me the formula ln(K2/K1) = DeltaH /R (T2 - T1 / T1T2) The answer is supposed to be in KJ/mol and I keep getting 2.022 but its not right. …
  10. Calculus 2

    A spring has a natural length of 25 meters. A force of 12 newtons is required to stretch the spring to a length of 30 meters. How much work is done to stretch the spring from it's natural length to 40 meters?

More Similar Questions