Results 1 to 7 of 7

Thread: [RESOLVED] Convert Meters to Feet

  1. #1

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    Resolved [RESOLVED] Convert Meters to Feet

    Maths was all about metric not feet and inchs when i was in school so i have no idea how to write feet and inches, i think its like 11' 11 1/16"

    When i use this:
    Code:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim mMetric As Double ="1.0" '1 meter
            'convert to feet
            Me.TextBox2.Text = CStr(mMetric * 3.28083)
        End Sub
    I get 3.28083, it will never give me a value with "x amount of feet and 11 inches" no matter what i put as the mMetric variable as it will always work on 10 units not 12.

    How can i get a accurate conversion?

    regards
    toe

  2. #2
    Hyperactive Member Max Peck's Avatar
    Join Date
    Oct 2007
    Posts
    384

    Re: Convert Meters to Feet

    Here, try this:

    vb Code:
    1. Private Sub MetersToFeet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MetersToFeet.Click
    2.  
    3.     Dim metric As Double
    4.     Dim english As Double
    5.     Dim feet As Integer
    6.     Dim inches As Integer
    7.  
    8.     metric = Val(txtDisplay.Text)
    9.     english = metric * 3.28083
    10.     feet = Int(english)
    11.     inches = (english - feet) * 12
    12.     txtDisplay.Text = feet & " feet " & inches & " inches"
    13.  
    14. End Sub

    -Max
    The name's "Peck" .... "Max Peck"

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." - Red Adair

  3. #3

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    Re: Convert Meters to Feet

    Max, nice thank you.

    I really need a result that i will be able to add together later on.

    Say i had these:

    2 feet 11 1/2 inches plus
    3 feet 11 3/8 inches

    how would i go about add those together if they where in separate textbox's?

    regards
    toe

  4. #4
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: Convert Meters to Feet

    What fractions do you want to support? It'd be easier if what you wrote was instead

    "2 feet 11.5 inches"
    "3 feet 11.375 inches"

    Fractions are possible, of course. If you really want them you can parse "11 1/2" into a whole part and a fractional part, but it's a bit unintuitive for me when I think about actually entering 11 1/2 on a form. I'd be likely to type random variants, like...

    "2 feet 11 and a half inches"
    "two feet 11 and 1 half inches"
    "2' 11 1/2" " [2" is using 1 double quote]
    "2' 11 1/2'' " [2'' is using 2 single quotes]
    ...

    It might (depending on your usage) be easiest to split input into three parts. The first would be the number of feet entered in a text box. The second would be the number of inches in another text box. The third part would be the fraction of inches. You could do this a few ways, but one would be a pair of textboxes, one for the numerator and one for the denominator. Perhaps the denominator would be a drop-down list box with standard increments, say "4", "8", "16", "32", and "64" for fourths, eighths, sixteenths, thirty-secondths, and sixty-fourths. It could be made pretty intuitive. Imagine ______ means a textbox is there. Then your interface would say...

    ______' _____ ___/___"
    Last edited by jemidiah; Dec 4th, 2009 at 05:53 AM.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  5. #5

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    Re: Convert Meters to Feet

    jemidiah, i am not exactly sure what fractions i need to support as i never seen coding for this type of thing.

    My target users are construction estimators in the US, i think i need to investigate what they need before designing anything.

    Thanks for your help
    toe

    edit
    How would one enter these into the standard calculator that comes with windows xp?
    2' 11 1/2"
    plus
    2' 11 5/16''
    Last edited by toecutter; Dec 4th, 2009 at 03:54 PM.

  6. #6
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: Convert Meters to Feet

    You couldn't enter those in the standard Windows XP calculator, not at all directly. You could add the feet and inches separately.

    //Feet
    2+2=4

    //Inches
    1/2=0.5
    5/16=0.3125
    11+1/2=11.5
    11+5/16=11.3125

    //Inches total, to feet
    11.5+11.3125=22.8125=1 foot 10.8125 inches

    //Sum it up and convert back to fractions
    =>5 feet 10.8125 inches
    = 5 feet 10 13/16 inches
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  7. #7

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    Re: Convert Meters to Feet

    Quote Originally Posted by jemidiah View Post
    You could do this a few ways, but one would be a pair of textboxes, one for the numerator and one for the denominator. Perhaps the denominator would be a drop-down list box with standard increments, say "4", "8", "16", "32", and "64" for fourths, eighths, sixteenths, thirty-secondths, and sixty-fourths. It could be made pretty intuitive. Imagine ______ means a textbox is there. Then your interface would say...

    ______' _____ ___/___"
    This is what i have gone with

    Thanks again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width