none
Feet And Inches RRS feed

  • General discussion

  • Feet And Inches – A Real Pain At Times!

    This is the situation:

    You need to place a piece of equipment – a rather large piece of equipment – on the roof of this new building. In various meetings and e-mails, you’ve all decided that the best location for this piece of equipment will be on a small parapet roof above the equipment room.

    So will it fit?

    The architect is still developing this area; ergo, it’s “subject to change without notice” so it’s a moving target but you need to get started anyway.

    Further though, you don’t yet know how big this equipment will be because the owners haven’t yet finalized their decisions on what they want – all of which will potentially change the selection of the unit (and subsequently the size of it) – oh and did I mention that notwithstanding THEIR hold-ups, both the owner and architect want a report about the placement by the end of the week! Ain’t life fun!

    Working with feet and inches can be a real hassle; you find yourself converting back and forth into common units and that alone is highly subject to error, especially when it’s late and you’ve done this so many times that you can’t even remember what revision you’re on.

    I’ve created a class which I hope some of you might find helpful. My idea here is to try to make this at least a bit more easy, thus ameliorating part of the pain of what I’ve come to know all too well in situations like this. ;-)

    I have the code for the class on a page of my website, but before showing the link to it, I’d rather first show you how it might be used in the following example which is somewhat similar to what I deal with rather commonly!

    *****

    I’m going to create a private sub in my form which will manipulate things at each step as I explain what’s going on here. So first, my sub (with no parameters – although in reality you might want to make this method a function with a return value) looks like this:

     

     Private Sub ShowUseOfFeetInchesClass()

     

     

     

       End Sub

     

    Not much to see there huh. ;-)

    Let’s set some variables which we can use later in that sub to indicate a few things:

    • Width of the available working area on the roof;
    • Length of the available working area on the roof;
    • Actual width of the new piece of equipment;
    • Actual length of the new piece of equipment;
    • Required clearance around the new piece of equipment, same requirement for all four sides;
    • Desired clearance on each side of the new equipment, per side.

     

    The type for each of these will be the type which this class is: A FeetInches class instance. The modified sub now looks like this:

     

      Private Sub ShowUseOfFeetInchesClass()

     

           Dim roofWorkableWidth As FeetInches = Nothing

           Dim roofWorkableLength As FeetInches = Nothing

           Dim equipmentActualWidth As FeetInches = Nothing

           Dim equipmentActualLength As FeetInches = Nothing

           Dim requiredMinimumClearance As FeetInches = Nothing

           Dim preferredClearance_HeaderEnd As FeetInches = Nothing

           Dim preferredClearance_OppositeHeaderEnd As FeetInches = Nothing

           Dim preferredClearance_TubeRunSide1 As FeetInches = Nothing

           Dim preferredClearance_TubeRunSide2 As FeetInches = Nothing

     

       End Sub

     

     

    As you can see above, I’m declaring all of the variables thus far as the type “FeetInches” and initially setting them all to be Nothing. The requirement now is to make some phone calls and get your needed information … the clock is ticking!

    *****

    So you call the architect and after his long martini lunch with … ok, sorry … and he tells you that he thinks the new roof in this area will be *about* forty-two feet long and *about* twenty-eight feet wide. Let’s at least get that in while we’re waiting on word back from the owners about their decisions on what direction to go. The new sub now looks like this:

     

    Private Sub ShowUseOfFeetInchesClass()

     

           Dim roofWorkableWidth As FeetInches = Nothing

           Dim roofWorkableLength As FeetInches = Nothing

           Dim equipmentActualWidth As FeetInches = Nothing

           Dim equipmentActualLength As FeetInches = Nothing

           Dim requiredMinimumClearance As FeetInches = Nothing

           Dim preferredClearance_HeaderEnd As FeetInches = Nothing

           Dim preferredClearance_OppositeHeaderEnd As FeetInches = Nothing

           Dim preferredClearance_TubeRunSide1 As FeetInches = Nothing

           Dim preferredClearance_TubeRunSide2 As FeetInches = Nothing

     

           roofWorkableLength = New FeetInches(42, 0)

           roofWorkableWidth = New FeetInches(28, 0)

     

       End Sub

     

     

    The last part you see there sets the appropriate variables to be NEW instances of the class (I don’t have any shared methods in it, so you need to instantiate it directly).

    Note the layout: The constructor is overloaded (two ‘versions’) and this is the primary one. In what you see above, I’m setting the roof’s workable length to 42 feet and 0 inches, and the workable width to 28 feet and 0 inches.

    Using this particular overload, the feet must be a whole number (an integer) but the inches can be either a whole number (integer) or a mixed number (double) The value for the inches (using this particular constructor) must be less than 12.

    We’ll examine just what that did later, but first a word from our commercial sponser!

    … kidding – I’ll continue this in a subsequent post.


    Please call me Frank :)

    Sunday, November 3, 2013 1:10 PM

All replies

  • Feet And Inches – A Real Pain At Times!
    (Continued)

    To continue:

    You finally get a call from the owners (they were having lunch with the architect…) and they inform you that they’ve decided what they want, so you now ‘work your magic’ and come up with a selection for the equipment which needs to go on the roof.

    This shows the dimensions of the equipment you intend to use (from an actual project of mine about a year ago).

    Don’t ya love it when manufacturers show dimensions in total feet or total inches rather than what you’re working with? Right – me too! This was part of the reason for doing all this, but don’t grab your pocket calculator just yet, let’s stick with the class that I built for now.

    I’m going to use the GREATER of the dimensions shown on that spec sheet as that’s what’s important here; the structural supports aren’t (at this time) of consideration, but rather, overall dimensions and clearance are.

    The sub now looks like this:

     

     Private Sub ShowUseOfFeetInchesClass()

     

           Dim roofWorkableWidth As FeetInches = Nothing

           Dim roofWorkableLength As FeetInches = Nothing

           Dim equipmentActualWidth As FeetInches = Nothing

           Dim equipmentActualLength As FeetInches = Nothing

           Dim requiredMinimumClearance As FeetInches = Nothing

           Dim preferredClearance_HeaderEnd As FeetInches = Nothing

           Dim preferredClearance_OppositeHeaderEnd As FeetInches = Nothing

           Dim preferredClearance_TubeRunSide1 As FeetInches = Nothing

           Dim preferredClearance_TubeRunSide2 As FeetInches = Nothing

     

           roofWorkableLength = New FeetInches(42, 0)

           roofWorkableWidth = New FeetInches(28, 0)

     

           equipmentActualWidth = New FeetInches(80.5, ThisValueRepresents.Inches)

           equipmentActualLength = New FeetInches(339.0, ThisValueRepresents.Inches)

     

       End Sub

     

     

    The instantiation of the actual width and length of the equipment uses another overload there. As you can see, you enter the value then tell it whether that value represents feet or inches.

    Take note of the declaration for the equipment length above: I used “339.0”. Why? You need to give it a clear indicator that the value you entered was a type double; otherwise it’ll be confused. That’s why.

    So let’s finish this out to see just where we are then – we now know the [preliminary] size of where the equipment is to go and the size of the equipment, so we should have what we need.

    The modified sub now looks like … followed up on the next post. :)


    Please call me Frank :)

    Sunday, November 3, 2013 1:10 PM
  • Feet And Inches – A Real Pain At Times!
    (Continued)

    To continue:

    The modified sub now looks like this:

    [The code was too long to include here so it’s shown on a page of my website here]

    Obviously a fair amount took place there, but essentially I set the values I wanted for the minimum required clearances and set the values for my preferences.

    The report, simple as it is, is shown below:

     

    Roof Usable Dimensions: 42'-0" Long x 28'-0" Wide

    Equipment Overall Dimensions: 28'-3" Long x 6'-8" Wide

     

    Total Clearance On Each End: 6'-10 1/2"

    Total Clearance On Each Side: 10'-7 3/4"

     

    Meets Minimum Required Length Clearance Of 3'-0": True

    Meets Minimum Required Width Clearance Of 3'-0": True

     

    Meets Preferred Clearance, Header Bank Side Of 6'-0": True

    Meets Preferred Clearance, Opposite Header Bank Side Of 4'-0": True

    Meets Preferred Clearance, Tube Run Side 1 Of 3'-0": True

    Meets Preferred Clearance, Tube Run Side 2 Of 3'-0": True

     

    In ‘real life’, those numbers will change many times before the deadline – hopefully though, this will make that task a little easier. I would create a function passing in the data needed, and have it pass back the ‘report’ text. That way, modification is as simple as changing the values passed into the function.

    This could obviously be greatly embellished, including whether to offset the unit from center and then arrive at the results, but you see that if the dimensions change, quickly the report will keep up with it and will display the results in a usable format – again though, basing this on passing in parameters which I didn’t do in this.

    Also, in actual practice it’s pretty rare that you don’t have to share the roof with *something* - ventilation for this and can’t impede airflow for that and … there’s almost never a situation where your equipment will be on that roof by itself, so in that sense, this example falls apart pretty easily. ;-)

    *****

    I have the code for the class shown on a page of my website here and I hope that some of you might find this useful sometime. :)

     

     


    Please call me Frank :)

    Sunday, November 3, 2013 1:11 PM
  • Hi Frank,

     You are always sharing something or another that is useful to people whether it is exactly what they are looking for or it gives them ideas how to write a similar code for themselves. Being a jack of all trades and i do a lot of building many different types of things, i find that there is always a need for measuring something or another.  I am sure this will come in handy for someone. Thanks for contributing this.    :)


    • Edited by IronRazerz Sunday, November 3, 2013 1:32 PM
    Sunday, November 3, 2013 1:32 PM
  • Hi Frank,

     You are always sharing something or another that is useful to people whether it is exactly what they are looking for or it gives them ideas how to write a similar code for themselves. Being a jack of all trades and i do a lot of building many different types of things, i find that there is always a need for measuring something or another.  I am sure this will come in handy for someone. Thanks for contributing this.    :)


    My pleasure

    I'll make a suggestion: You might consider making this shared (static) by doing the following:

    Add a new shared method (a function) and call it something like "CreateNew", or some such. Now set up an empty contructor:

    Public Sub New()
        Throw New ArgumentException("You cannot instantiate...")
    End Sub

    Now set the actual Sub New constructors to be PRIVATE, so that the only way that the consumer can instantiate the class is via your shared method. In that function, have it return an instance of itself (which sounds sort of weird, but it works -- so long as the method is shared (static)).

    What's the purpose of all that?

    That way, you can use it as though it's a member of the Math family, but you simply specify the name "FeetInches" instead.

    The reason that I didn't do that is because that's actually a part of a much larger class library and I have hundreds of calls to that class -- I was lazy and didn't want to change what I already had done! ;-)


    Please call me Frank :)

    Sunday, November 3, 2013 1:39 PM
  • Hello Frank,

    Thanks for sharing. Do I get the feeling you don't like roof work :-)


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Sunday, November 3, 2013 2:14 PM
    Moderator
  • Do I get the feeling you don't like roof work :-)

    Ha! Roofwork doesn't bother me, architects with capricious whims do! ;-)

    *****

    In the class library I'm building, it's used for more than just roofwork though:

    Public Sub New(ByVal doorName As String, _ ByVal doorHeight As RefLoadCommon.FeetInches, _ ByVal doorWidth As RefLoadCommon.FeetInches, _ ByVal minutesOpen As Double, _ ByVal refrigeratedSpaceConditions As PsychrometricProperties, _ ByVal oppositeSideConditions As PsychrometricProperties, _ Optional ByVal thermalEfficacyPercent As Double = 0) If doorName.Trim = "" Then Throw New ArgumentException("The door name cannot be empty.") ElseIf minutesOpen < 0 Then Throw New ArgumentException("The minutes that the door is open must be a non-negative number.") ElseIf thermalEfficacyPercent > 1 Then Throw New ArgumentException("The thermal efficacy cannot exceed 100% (i.e., a value of 1).") ElseIf thermalEfficacyPercent < 0 Then Throw New ArgumentException("The thermal efficacy cannot be less than zero.") Else _doorName = doorName.Trim _doorHeightInClear = doorHeight _doorWidthInClear = doorWidth _minutesOpen = minutesOpen _refrigeratedSpaceConditions = refrigeratedSpaceConditions _oppositeSideConditions = oppositeSideConditions _thermalBarrierEffectiveness = thermalEfficacyPercent Dim td As Double = Math.Abs(refrigeratedSpaceConditions.DryBulbTemperature - _ oppositeSideConditions.DryBulbTemperature) _velocityFPM = 100 * ((Math.Sqrt(_doorHeightInClear.TotalFeet) / Math.Sqrt(7)) * (Math.Sqrt(td) / Math.Sqrt(60))) _rateOfInfiltrationCFM = _velocityFPM * _ ((_doorHeightInClear.TotalFeet * _doorWidthInClear.TotalFeet) / 2) * (1 - _thermalBarrierEffectiveness) _rateOfInfiltrationCFH = _rateOfInfiltrationCFM * minutesOpen _poundsOfInfiltratingAir = _rateOfInfiltrationCFH / oppositeSideConditions.SpecificVolume _deltaH = Math.Abs(_refrigeratedSpaceConditions.Enthalpy - _oppositeSideConditions.Enthalpy) _refrigerationLoadBTUH = _poundsOfInfiltratingAir * _deltaH _refrigerationLoadBTU24 = _refrigerationLoadBTUH * 24 'Dim areaSF As Double = doorHeight.TotalFeet * doorWidth.TotalFeet 'Dim testMe As Double = ((4.88 * Math.Sqrt(doorHeight.TotalFeet) * (areaSF / 2) * _ ' minutesOpen * Math.Sqrt(td)) * deltaH) / _oppositeSideConditions.SpecificVolume End If End Sub


    ...so it really does come in handy. ;-)


    Please call me Frank :)

    Sunday, November 3, 2013 2:26 PM
  • So you call the architect and after his long martini lunch with …

    Sounds like the behaviour we suspect of some of our clients, lol.

    How about doing the UI in Imperial units and the internals in metric? What could possibly go wrong?

    --
    Andrew

    Sunday, November 3, 2013 4:15 PM
  • How about doing the UI in Imperial units and the internals in metric? What could possibly go wrong?

    --
    Andrew

    I can do that, but ... what are the metric units?

    On another thing I was working on a while back, if you're up for it, I'd like to ask you about common units of a few things (in SI, that is).


    Please call me Frank :)

    Sunday, November 3, 2013 4:23 PM
  • On another thing I was working on a while back, if you're up for it, I'd like to ask you about common units of a few things (in SI, that is).

    Of course you can. If it's a bit OT for this forum, you can email me at edit: please request email address if desired. I have to say I am not an expert in measurement units or dimensional analysis by any stretch of the imagination.

    --
    Andrew


    • Edited by Andrew Morton Tuesday, November 5, 2013 10:48 PM Removed obfuscated email address.
    Sunday, November 3, 2013 4:47 PM
  • Of course you can. If it's a bit OT for this forum, you can email me at ntlworld.com, with andrew.morton1 as the name. I have to say I am not an expert in measurement units or dimensional analysis by any stretch of the imagination.

    Well it is but let's leave it this and if it gets involved then we'll move to another mode of communication:

    If you'll have a look at page one of this, you'll see the units currently in use in that program. If you happen to know what they would most likely be in SI, I'd be much appreciative!


    Please call me Frank :)

    Sunday, November 3, 2013 4:54 PM
  • Temperature: degrees Celsius (although Kelvin makes more sense in thermodynamic calculations).

    Pressure: N/m^2

    Density: kg/m^3

    Specific volume: m^3/kg

    Enthalpy: J/kg

    Don't forget that PSIG is (PSIA-atmospheric pressure at the time of measurement).

    HTH,

    Andrew

    Sunday, November 3, 2013 5:08 PM
  • Temperature: degrees Celsius (although Kelvin makes more sense in thermodynamic calculations).

    Pressure: N/m^2

    Density: kg/m^3

    Specific volume: m^3/kg

    Enthalpy: J/kg

    Don't forget that PSIG is (PSIA-atmospheric pressure at the time of measurement).

    HTH,

    Andrew

    Everything in the raw data is in PSIA and truth be known, that's what's used in the calculations no matter what units of display they want.

    I actually guessed about half of that right, but -- it was just that, a guess, so many thanks Andrew! :)


    Please call me Frank :)

    Sunday, November 3, 2013 5:10 PM
  • Hi Frank,

    Just for discussions sake, this could be a good example of class versus structure.

    In this case the FeetInches value could be thought of as a wrapper for Decimal.  A structure could be built which only holds a single decimal value representing the total length in one unit or the other (choose feet or inches as the standard unit).  Then the other unit can be exposed via members of the structure (property or method, but method may make more sense since there will be a calculation involved in getting the result).

    Since the FeetInches object will likely be used as a numeric value throughout its lifetime it may make sense to treat it as a value type and let it live on the stack.

    Obviously this changes the usage somewhat and you may not find it as friendly, so I can understand sticking with the class-based design in some scenarios.  But in the most general sense, this seems like a fine candidate for a structure.  Here's a little example using a different name so that it could easily be compared and contrasted with your existing class (if you or anyone else are interested):

    Option Strict On
    
    Public Class Form1
    
        Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            'Dim f1 As FootInch = FootInch.FromFeet(2.25D)
            Dim f1 As FootInch = FootInch.FromBoth(2D, 3D)
            Debug.Print(f1.TotalFeet.ToString)
            Debug.Print(f1.TotalInches.ToString)
            Debug.Print(f1.FootPart.ToString)
            Debug.Print(f1.InchPart.ToString)
            Debug.Print(f1.ToString)
        End Sub
    End Class
    
    <Serializable()>
    Public Structure FootInch
        Implements IComparable(Of FootInch)
    
        Public Const InchesPerFoot As Decimal = 12D
    
        Public Shared ReadOnly Zero As New FootInch
    
        Public Shared Function FromBoth(feet As Decimal, inches As Decimal) As FootInch
            Return New FootInch With {._Value = feet + (inches / InchesPerFoot)}
        End Function
    
        Public Shared Function FromFeet(feet As Decimal) As FootInch
            Return New FootInch With {._Value = feet}
        End Function
    
        Public Shared Function FromInches(inches As Decimal) As FootInch
            Return New FootInch With {._Value = inches / InchesPerFoot}
        End Function
    
        Private _Value As Decimal
    
        Public Function CompareTo(other As FootInch) As Integer Implements System.IComparable(Of FootInch).CompareTo
            Return _Value.CompareTo(other._Value)
        End Function
    
        Public Function FootPart() As Decimal
            Return Math.Floor(_Value)
        End Function
    
        Public Function InchPart() As Decimal
            Return _Value * InchesPerFoot Mod InchesPerFoot
        End Function
    
        Public Function TotalFeet() As Decimal
            Return _Value
        End Function
    
        Public Function TotalInches() As Decimal
            Return _Value * InchesPerFoot
        End Function
    
        Public Overrides Function Equals(obj As Object) As Boolean
            If TypeOf obj Is FootInch Then
                Return _Value.CompareTo(DirectCast(obj, FootInch)) = 0
            End If
            Return False
        End Function
    
        Public Overrides Function GetHashCode() As Integer
            Return _Value.GetHashCode
        End Function
    
        Public Overrides Function ToString() As String
            Return String.Format("{0}' {1}""", FootPart, InchPart)
        End Function
    
        Public Shared Operator =(source As FootInch, target As FootInch) As Boolean
            Return source.Equals(target)
        End Operator
    
        Public Shared Operator <>(source As FootInch, target As FootInch) As Boolean
            Return Not source = target
        End Operator
    
        Public Shared Operator >(source As FootInch, target As FootInch) As Boolean
            Return source.CompareTo(target) > 0
        End Operator
    
        Public Shared Operator <(source As FootInch, target As FootInch) As Boolean
            Return source.CompareTo(target) < 0
        End Operator
    
        Public Shared Operator >=(source As FootInch, target As FootInch) As Boolean
            Return source.CompareTo(target) >= 0
        End Operator
    
        Public Shared Operator <=(source As FootInch, target As FootInch) As Boolean
            Return source.CompareTo(target) <= 0
        End Operator
    
        Public Shared Operator +(source As FootInch, target As FootInch) As FootInch
            Return New FootInch With {._Value = source._Value + target._Value}
        End Operator
    
        Public Shared Operator -(source As FootInch, target As FootInch) As FootInch
            Return New FootInch With {._Value = source._Value + target._Value}
        End Operator
    
        Public Shared Operator *(source As FootInch, target As FootInch) As FootInch
            Return New FootInch With {._Value = source._Value + target._Value}
        End Operator
    
        Public Shared Operator /(source As FootInch, target As FootInch) As FootInch
            Return New FootInch With {._Value = source._Value + target._Value}
        End Operator
    End Structure

    There is a school of thought which says that core value types like Integer and Decimal should not be used if there is a logically stronger type they can be wrapped into.  With this line of thinking you would create wrapper objects for everything; for example, an "Age" property on a "Person" object would not be an Integer - it would be a "PersonAge" object which is a wrapped integer which only accepts values of 1 through 120 (ok, a rough example).

    I don't necessarily think that every property type which could be wrapped should be wrapped, but when it makes a lot of sense (like in your case) it is definitely a great idea.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Sunday, November 3, 2013 5:41 PM
    Moderator
  • FWIW - accept ft / inches as string.  Just some ideas.

    Class test
        Private _inches As Double = 0
        Private _feet As Double = 0
    
        Public Sub New(s As String)
            '  42'  or    42.5'  or  28' 3"  or  6' 10 3/8"  or  3/8"  or  6' 10.5"  or  3"
    
            Dim parts() As String
    
            If s.Contains("'") AndAlso s.Contains(ControlChars.Quote) Then
                'feet and inches
                parts = s.Split(New Char() {"'"c})
                Me._feet = ProcessPart(parts(0))
                Me._inches = ProcessPart(parts(1).Replace("-"c, " "))
            ElseIf s.Contains("'") Then
                'just feet
                Me._feet = ProcessPart(s)
            ElseIf s.Contains(ControlChars.Quote) Then
                'just inches
                Me._inches = ProcessPart(s)
            End If
            If Me._feet > 0 AndAlso Me._feet Mod Math.Floor(Me._feet) <> 0 Then
                Me._inches += (Me._feet Mod Math.Floor(Me._feet)) * 12
                Me._feet = Math.Floor(Me._feet)
            End If
            If Me._inches >= 12 Then
                Dim foo As Long = CLng(Me._inches) \ 12
                Me._feet += foo
                Me._inches -= foo * 12
            End If
        End Sub
    
        Private Function ProcessPart(s As String) As Double
            Dim retval As Double
            Dim frac As Double
            s = s.Replace("'"c, "").Replace(""""c, "") 'get rid of ' and "
            Dim parts() As String = s.Split(New Char() {" "c}, StringSplitOptions.RemoveEmptyEntries)
            For Each p As String In parts
                If p.Contains("/") Then
                    Dim f() As String = p.Split(New Char() {"/"c}, StringSplitOptions.RemoveEmptyEntries)
                    If Not (Integer.TryParse(f(0), Nothing) AndAlso Integer.TryParse(f(1), Nothing)) Then
                        Stop 'error
                    End If
                    frac = Integer.Parse(f(0)) / Integer.Parse(f(1))
                Else
                    If Not Double.TryParse(p, retval) Then
                        Stop 'error
                    End If
                End If
            Next
            Return retval + frac
        End Function
    
        Public Function asString() As String
            Return (String.Format("{0}' {1}""", Me._feet, Me._inches))
        End Function
    End Class
    



    "Those who use Application.DoEvents() have no idea what it does and those who know what it does never use it." JohnWein



    • Edited by dbasnett Sunday, November 3, 2013 6:31 PM
    Sunday, November 3, 2013 5:42 PM
  • Reed,

    I actually hadn't considered that, but you're right - this is a good candidate for a structure.

    Thanks for the insight. :)


    Please call me Frank :)

    Sunday, November 3, 2013 5:49 PM
  • Thanks DB,

    Actually I did think about doing it the other way around - string in, an instance of the class out, but what I envisioned to be an issue was formatting.

    The string would have to conform to [some standard] format, don't you think?

    Thanks! :)


    Please call me Frank :)

    Sunday, November 3, 2013 5:50 PM
  • Thanks DB,

    Actually I did think about doing it the other way around - string in, an instance of the class out, but what I envisioned to be an issue was formatting.

    The string would have to conform to [some standard] format, don't you think?

    Thanks! :)


    Please call me Frank :)

    Sure.  I coded for most of the ones I've seen.  I did miss feet.partial feet.  I'll edit in place for that.

    edit done

    Did you see this error

    sb.AppendLine("Formatted Feed And Inches: " & TotalFeetAndInches_String)  Were you hungry :)


    "Those who use Application.DoEvents() have no idea what it does and those who know what it does never use it." JohnWein


    • Edited by dbasnett Sunday, November 3, 2013 6:06 PM
    Sunday, November 3, 2013 6:00 PM
  • Sure.  I coded for most of the ones I've seen.  I did miss feet.partial feet.  I'll edit in place for that.

    Well it also has to include some form of validation.

    As an example, I once knew this guy who was "a really big dude". I'm 6'-0" to 6'-1", depending on which doctor I go to or when in my life it was (we all get shorter as we get older).

    This guy just towered over me. As should come as no surprise, he became really tired of hearing "wow, how tall are you?", so he came to answer it like this:

    "I'm five foot nineteen"


    Please call me Frank :)

    Sunday, November 3, 2013 6:05 PM
  • Sure.  I coded for most of the ones I've seen.  I did miss feet.partial feet.  I'll edit in place for that.

    Well it also has to include some form of validation.

    As an example, I once knew this guy who was "a really big dude". I'm 6'-0" to 6'-1", depending on which doctor I go to or when in my life it was (we all get shorter as we get older).

    This guy just towered over me. As should come as no surprise, he became really tired of hearing "wow, how tall are you?", so he came to answer it like this:

    "I'm five foot nineteen"


    Please call me Frank :)


    I agree.  Some of the obvious stuff I didn't do, like 13".  I also see that you like '-' as a separator which would be an easy fix.  Check out the edits.

    "Those who use Application.DoEvents() have no idea what it does and those who know what it does never use it." JohnWein

    Sunday, November 3, 2013 6:30 PM
  • Frank,

    In history the pain was even worse. Every country and for instance in the Netherlands even every province had its own definition of what was an inch and what was a feet. (In fact the wide of a thumb and length of a feet). 

    However, almost the whole world outside the British imperium changed to the in French founded metric system and now even the British themselves have officially changed to the metric system although persons still use the old system.  (It is easier to use and more reliable). AFAIK is only the USA still on a system that derived from the Imperial Units System 

    However that is just around this discussion. Just as an advice, if you make code for demonstrations. Then try to use everywhere on global level Access Modifiers and use Properties if it those are Public or Friend.

    About the use of properties I've always been sceptic and I still am. But there are some advantages like better showing up in intellisense en tools. With the new automatic properties there is almost no writing time lost by using them.


    Success
    Cor



    Sunday, November 3, 2013 6:32 PM
  • Did you see this error

    sb.AppendLine("Formatted Feed And Inches: " & TotalFeetAndInches_String)  Were you hungry :)

    Ha! Freudian!

    I'll go back to this sometime next week if I can. I think what I'll do is to pull that class out of my namespace (it works for what I need it for), then I can work on it at length.

    Thanks!


    Please call me Frank :)

    Sunday, November 3, 2013 6:39 PM
  • Just as an advice, if you make code for demonstrations. Then try to use everywhere on global level Access Modifiers and use Properties if it those are Public or Friend.

    About the use of properties I've always been sceptic and I still am. But there are some advantages like better showing up in intellisense en tools. With the new automatic properties there is almost no writing time lost by using them.

    I'm confused -- where did I not use an access modifier that I should have? Or are you maybe referring to Option Infer? In this code, it's set to "ON". That's really another discussion though.

    I don't understand the comment about properties. A property is a pretty simple thing - what's to be skeptical of?


    Please call me Frank :)

    Sunday, November 3, 2013 6:42 PM
  • Just as an advice, if you make code for demonstrations. Then try to use everywhere on global level Access Modifiers and use Properties if it those are Public or Friend.

    About the use of properties I've always been sceptic and I still am. But there are some advantages like better showing up in intellisense en tools. With the new automatic properties there is almost no writing time lost by using them.

    I'm confused -- where did I not use an access modifier that I should have? Or are you maybe referring to Option Infer? In this code, it's set to "ON". That's really another discussion though.

    I don't understand the comment about properties. A property is a pretty simple thing - what's to be skeptical of?


    Please call me Frank :)

    Access modifieres are Public, Friend and more. I've looked to the code on your websites. I see a lot of Members which miss those.

    By the way, I miss the clue of your sentence of skeptical. I simply try to help you to do it better, are you maybe reading replies all as negative critique?


    Success
    Cor

    Sunday, November 3, 2013 7:54 PM
  • Cor,

    I'm not trying to pick a fight with you, although you and I have looooong history of just that, so let's leave it where it is.

    I see nothing wrong with how I have it done; your opinion obviously differs, but - that's life. :)


    Please call me Frank :)

    Sunday, November 3, 2013 8:00 PM
  • I've modified this to an extent, not yet taking in some of the suggestions.

    DB found an error and I found another, both of which have been corrected in this, but mainly it's now re-organized.

    There's now a namespace called "Measurement" and in that, two namespaces:

    • SI
    • IP

    I'm only addressing the IP namespace in this.

    I've renamed "FeetInches" to "SingleDimensionalMeasurement" because I think that's more apropos for what it really is; it just happens to be in feet and inches, but that's the rationale behind the namespace it's in (IP).

    There are two other classes:

    "TwoDimensionalMeasurement", and "ThreeDimensionalMeasurement", each of those being classes which will return properties - the properties each being a "SingleDimensionalMeasurement".

    I need to at least embellish those a bit, but I thought I'd toss this out as it is and see what folks think.

    The code is shown here on my website.

    :)


    Please call me Frank :)

    Monday, November 4, 2013 8:41 PM
  • I need to at least embellish those a bit, but I thought I'd toss this out as it is and see what folks think.

    Frank,

    Once you have this done you should (and I have said this before) write an MSDN article so the code is available to anyone in this forum or outside of these forums. I believe I gave you information on writing articles before. 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Monday, November 4, 2013 8:53 PM
    Moderator
  • I need to at least embellish those a bit, but I thought I'd toss this out as it is and see what folks think.

    Frank,

    Once you have this done you should (and I have said this before) write an MSDN article so the code is available to anyone in this forum or outside of these forums. I believe I gave you information on writing articles before. 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Is that another way of saying that you're tired of reading this post? Actually, I understand. ;-)

    If you log in and go to this thread, one of your options is to uncheck the "Subscribe" - so you won't be bothred with it in e-mail.


    Please call me Frank :)

    Monday, November 4, 2013 9:01 PM
  • One thing you might consider adding to your FeetInches class, is the ability to add and subtract them.  Overload the + and - operators so that you can add or subtract them, like this:

    Dim length1 As New FeetInches(42, 8) Dim length2 As New FeetInches(28, 6) Dim totalLength As FeetInches = length1 + length2

    'Result: 71' 2"



    Tuesday, November 5, 2013 10:04 PM
  • One thing you might consider adding to your FeetInches class, is the ability to add and subtract them.  Overload the + and - operators so that you can add or subtract them, like this:

    Dim length1 As New FeetInches(42, 8) Dim length2 As New FeetInches(28, 6) Dim totalLength As FeetInches = length1 + length2

    'Result: 71' 2"



    Chris, that's nothing short of pure brilliant!

    Yes!

    I think I'll go back to my basic way though - not what I posted yesterday, but I agree that's a great idea.

    Thanks! :)


    Please call me Frank :)

    Tuesday, November 5, 2013 10:15 PM
  • One thing you might consider adding to your FeetInches class, is the ability to add and subtract them.

    Then you'll be wanting to multiply them to get areas and volumes, and also divide them to get lengths and areas, etc. Gotta love this feet-and-inches thing ;)

    --

    Andrew

    Tuesday, November 5, 2013 10:59 PM
  • Then you'll be wanting to multiply them to get areas and volumes, and also divide them to get lengths and areas, etc. Gotta love this feet-and-inches thing ;)

    Right! ;-)


    Please call me Frank :)

    Wednesday, November 6, 2013 12:41 AM
  • All I know about this thread is the Architect and the Owners would be getting an earful of distasteful static from me, hammered over and over to both of them at the same time, with very unpleasant innuendos thrown in faster than a pair of New York seconds in every sentence as I molested their ears constantly with no regard for their thoughts right before I spewed saliva onto the ground and left the job permanently.


    Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you post an image it clutters up the thread and mysteriously, over time, the link to the image will somehow become "unstable" or something to that effect. :) I can only surmise that is due to Global Warming of the threads.


    • Edited by Mr. Monkeyboy Wednesday, November 6, 2013 1:18 AM 5555
    Wednesday, November 6, 2013 1:10 AM
  • All I know about this thread is the Architect and the Owners would be getting an earful of distasteful static from me, hammered over and over to both of them at the same time, with very unpleasant innuendos thrown in faster than a pair of New York seconds in every sentence as I molested their ears constantly with no regard for their thoughts right before I spewed saliva onto the ground and left the job permanently.


    Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you post an image it clutters up the thread and mysteriously, over time, the link to the image will somehow become "unstable" or something to that effect. :) I can only surmise that is due to Global Warming of the threads.



    It's just reality -- I'm used to it. ;-)

    Please call me Frank :)

    Wednesday, November 6, 2013 1:30 AM
  • Is that what you do for a living Frank? Something regarding construction or an electrician or something? I figured you were a programmer for a living.

    Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you post an image it clutters up the thread and mysteriously, over time, the link to the image will somehow become "unstable" or something to that effect. :) I can only surmise that is due to Global Warming of the threads.

    Wednesday, November 6, 2013 1:40 AM
  • Is that what you do for a living Frank? Something regarding construction or an electrician or something? I figured you were a programmer for a living.

    I'm a mechanical engineer (albeit focused in a specialized area) - I'd starve if I were the latter!

    ;-)

    I started programming mainly to build "tools" for myself to do things more easily, especially repetitive tasks (like this one). Also though, the logic (which is math) always fascinated me - and still does.


    Please call me Frank :)

    Wednesday, November 6, 2013 1:46 AM
  • One of my nieces husband is going to Florida Institute of Technology to get a degree in, if I'm not mistaken, civil engineering. He's been working out at Kennedy Space Center for Lockheed Martin I think in logistics and has a business degree of some sort but the real bucks in that area comes from engineering. He has friends he went to high school with that became engineers and are making over 100k already and they're in the 27 to 29 yoa range and I suppose he's making about half that. So he can only take a few courses a semester as work is necessary since they just bought a nice house in West Melbourne where I used to work at a satellite communications company for a while (until about 2 years after the .com bubble burst) where I moved up the ladder in 5 years from a technician to a senior engineer. Lol, did I have everybody fooled!

    So I'm hoping he does well in that endeavor as he would truly enjoy the immediate pay raise although his experience level would leave him at the bottom of that ladder for a few years I suppose. But he'd still be making more than he does now right off the bat.


    Please BEWARE that I have NO EXPERIENCE and NO EXPERTISE and probably onset of DEMENTIA which may affect my answers! Also, I've been told by an expert, that when you post an image it clutters up the thread and mysteriously, over time, the link to the image will somehow become "unstable" or something to that effect. :) I can only surmise that is due to Global Warming of the threads.


    • Edited by Mr. Monkeyboy Wednesday, November 6, 2013 2:02 AM 5555
    Wednesday, November 6, 2013 2:01 AM
  • Hi Frank,

    I've picked up on this bit.

    >>

    ElseIf inches >= 12 Then

                       Throw New ArgumentException("The inches cannot exceed 11 (inches)."

    I think you should change it to.

    >>

    ElseIf inches >= 12 Then

                       Throw New ArgumentException("The inches cannot exceed 12 (inches)."

    as you are using DOUBLE values you could say have 5 feet 11 + 1/2 inches.

    From my own viewpoint I would have the following sub-classes under SI and IP.

    Length, Area, Volume

    Are you sure about this summary?

    >>

     ''' <summary>

               ''' Creates a new instance of a two-dimensional object consisting of a

               ''' length and a width, each being an instance of a SingleDimensionalMeasurement type.

               ''' </summary>

               ''' <param name="length">The length of this object (type SingleDimensionalMeasurement).</param>

               ''' <param name="width">The width of this object (type SingleDimensionalMeasurement).</param>

               ''' <param name="height">The height of this object (type SingleDimensionalMeasurement).</param>

               ''' <remarks></remarks>

    under ThreeDimensionalMeasurement

    You may also want to look at this website which may make you wish to integrate SI and IP ( Imperial ) into one CLASS

    so it is easier to convert between them.

    >>

    http://www.allconversions.com/

    It may help you with your bigger project. With my best regards ( no malice intended either )....


    Regards,

    profile for John Anthony Oliver at Stack Overflow, Q&A for professional and enthusiast programmers

    Click this link to see the NEW way of how to insert a picture into a forum post.

    Installing VB6 on Windows 7

    App Hub for Windows Phone & XBOX 360 developers.


    Wednesday, November 6, 2013 2:18 AM
  • Hi Frank,

    I've picked up on this bit.

    >>

    ElseIf inches >= 12 Then

                       Throw New ArgumentException("The inches cannot exceed 11 (inches)."

    I think you should change it to.

    >>

    ElseIf inches >= 12 Then

                       Throw New ArgumentException("The inches cannot exceed 12 (inches)."

    as you are using DOUBLE values you could say have 5 feet 11 + 1/2 inches.

    From my own viewpoint I would have the following sub-classes under SI and IP.

    Linear, Area, Volume

    Are you sure about this summary?

    >>

     ''' <summary>

               ''' Creates a new instance of a two-dimensional object consisting of a

               ''' length and a width, each being an instance of a SingleDimensionalMeasurement type.

               ''' </summary>

               ''' <param name="length">The length of this object (type SingleDimensionalMeasurement).</param>

               ''' <param name="width">The width of this object (type SingleDimensionalMeasurement).</param>

               ''' <param name="height">The height of this object (type SingleDimensionalMeasurement).</param>

               ''' <remarks></remarks>

    under ThreeDimensionalMeasurement

    You may also want to look at this website which may make you wish to integrate SI and IP ( Imperial ) into one CLASS

    so it is easier to convert between them.

    >>

    http://www.allconversions.com/

    It may help you with your bigger project. With my best regards ( no malice intended either )....

    Thanks John,

    Sorry for the delay - I had to be in a meeting this morning.

    Originally the inches was a type integer - and I forgot about that once I changed it to a type double. I think maybe "less than twelve inches" would be a better wording.

    I thought about making it a base class that would be inherited - and I may yet - but I think I'm going to back to what it was originally supposed to be: A type with no methods. Then I'll have other classes manipulate them however they need to be.

    I may or may not change it in the original namespace I have them in - it works for my purpose there, but maybe it's given others something to work with even if they change it around.

    Thanks for your input :)

    I haven't seen you around in a while. I hope you are well.


    Please call me Frank :)

    Wednesday, November 6, 2013 4:32 PM
  • I looked at the source for http://www.allconversions.com/

    and the conversion factors are embedded in the page.


    "Those who use Application.DoEvents() have no idea what it does and those who know what it does never use it." JohnWein

    Wednesday, November 6, 2013 4:56 PM

  • Thanks for your input :)

    I haven't seen you around in a while. I hope you are well.


    Please call me Frank :)

    Hi Frank,

    I have in recent years thought about a career in software development but I think I've changed my mind.

    Having reached 48, I am not sure what I plan on doing in the near future. I am thinking of a career in teaching for my last 18 or so years of working before I retire or whatever.

     I am well enough to still be working, many thanks for asking. :-)    :-D  I hope you are well too.

     I still have a few slight ongoing health issues though. I have been messing with other operating systems a bit lately and VIRTUALISATION. My interest in programming and VbNet is almost zero lately. The 'magic' has gone out of it for me. I am not sure why I feel like this either, I think it is because I'm thinking of my health more lately and I've been putting more hours in at work.

     I need to try and manage my own leisure time better.  LOL!!

     I am not keen on the newer forum look and this has been another factor for me not frequenting these forum pages lately although I still have an odd glance in at the 1st page of posts from time to time. Old habits die hard I guess.


    Regards,

    profile for John Anthony Oliver at Stack Overflow, Q&A for professional and enthusiast programmers

    Click this link to see the NEW way of how to insert a picture into a forum post.

    Installing VB6 on Windows 7

    App Hub for Windows Phone & XBOX 360 developers.


    Wednesday, November 6, 2013 7:42 PM
  • John,

    Well, pop in every once in a while at least. :)


    Please call me Frank :)

    Wednesday, November 6, 2013 7:55 PM
  • John,

    Well, pop in every once in a while at least. :)


    Please call me Frank :)

    Hi Frank,

    Okay, I will, even if it is only once a week / fortnight / month.  :-)


    Regards,

    profile for John Anthony Oliver at Stack Overflow, Q&A for professional and enthusiast programmers

    Click this link to see the NEW way of how to insert a picture into a forum post.

    Installing VB6 on Windows 7

    App Hub for Windows Phone & XBOX 360 developers.

    Wednesday, November 6, 2013 8:03 PM