calculation height to millimeters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cdm2883
    New Member
    • Sep 2007
    • 53

    calculation height to millimeters

    have to take the height of a person and calculate it into millimeters how do i go about doing that?!
  • cdm2883
    New Member
    • Sep 2007
    • 53

    #2
    Originally posted by cdm2883
    have to take the height of a person and calculate it into millimeters how do i go about doing that?!
    without using a msgbox.

    Comment

    • kadghar
      Recognized Expert Top Contributor
      • Apr 2007
      • 1302

      #3
      Originally posted by cdm2883
      have to take the height of a person and calculate it into millimeters how do i go about doing that?!
      do you mean the height in feet??

      well since 1 feet = 304.8 mm

      if you dont want a msgbox, lets say you have 2 txt boxes and a commandbutton that should say something like this:

      textbox2.text= textbox1.text * 304.8

      HTH

      Comment

      • cdm2883
        New Member
        • Sep 2007
        • 53

        #4
        Originally posted by kadghar
        do you mean the height in feet??

        well since 1 feet = 304.8 mm

        if you dont want a msgbox, lets say you have 2 txt boxes and a commandbutton that should say something like this:

        textbox2.text= textbox1.text * 304.8

        HTH

        doing the code in a console application

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by cdm2883
          doing the code in a console application
          Can you give us some idea of what you actually want help with? For instance, entering the information into your program, doing the calculation to mm (from what)? And so on.

          And what version of VB are you using?

          Comment

          • cdm2883
            New Member
            • Sep 2007
            • 53

            #6
            Originally posted by Killer42
            Can you give us some idea of what you actually want help with? For instance, entering the information into your program, doing the calculation to mm (from what)? And so on.

            And what version of VB are you using?

            I am using VB 2005

            I need help with how to start the code! I have no clue of what to type to start. I wrote the code for the person to enter their height in feet and inches, and now I have to write the code to calculate it to millimeters, and I have no idea how to start. Or what key words to use.

            Comment

            • Robbie
              New Member
              • Mar 2007
              • 180

              #7
              So you have the Feet and Inches stored?
              If so, here's how you can convert them to millimeters.
              I'll pretend your two variables so far are called vHeightFeet and
              vHeightInches, so change my code to suit what you've actually called them.
              [code=vb]
              Dim vHeightmm As Double
              'We prepared a new variable in which to hold the converted length in mm

              vHeightmm = (vHeightFeet + (vHeightInches/12)) * 304.8
              'We just converted Feet+Inches into mm and stored it in the vHeightmm variable

              EXPLANATION:
              Kadghar said that 1ft = 304.8mm
              So we want to know how many feet and inches there are, in feet only.
              Since there are 12 inches in a foot, if we divide the inches by 12, we get that equivalent length in feet (i.e. a decimal value less than 1).
              This, plus the number of feet, equals the number of feet 'in decimal'.
              Example: 1 foot 6 inches
              6 inches divided by 12 = 0.5 feet
              1 foot + 0.5 feet = 1.5 feet = 1 foot 6 inches 'in decimal'

              Then we multiply this final value - 1.5 - by 304.8 to convert it to milimeters, and store it in variable vHeightmm.
              This variable is declared as a 'Double' data type, meaning a number which can get very big, and have very accurate decimal points.

              Comment

              • Robbie
                New Member
                • Mar 2007
                • 180

                #8
                ...Right, the strange 'blank post' bug on this forum cropped up again, so I'll try again:


                So you have the Feet and Inches stored?
                If so, here's how you can convert them to millimeters.
                I'll pretend your two variables so far are called vHeightFeet and
                vHeightInches, so change my code to suit what you've actually called them.
                [code=vb]
                Dim vHeightmm As Double
                'We prepared a new variable in which to hold the converted length in mm

                vHeightmm = (vHeightFeet + (vHeightInches/12)) * 304.8
                'We just converted Feet+Inches into mm and stored it in the vHeightmm variable
                [/code]

                EXPLANATION:
                Kadghar said that 1ft = 304.8mm
                So we want to know how many feet and inches there are, in feet only.
                Since there are 12 inches in a foot, if we divide the inches by 12, we get that equivalent length in feet (i.e. a decimal value less than 1).
                This, plus the number of feet, equals the number of feet 'in decimal'.

                Example: 1 foot 6 inches
                6 inches divided by 12 = 0.5 feet
                1 foot + 0.5 feet = 1.5 feet = 1 foot 6 inches 'in decimal'

                Then we multiply this final value - 1.5 - by 304.8 to convert it to milimeters, and store it in variable vHeightmm.
                This variable is declared as a 'Double' data type, meaning a number which can get very big, and have very accurate decimal points.

                Comment

                • cdm2883
                  New Member
                  • Sep 2007
                  • 53

                  #9
                  Originally posted by Robbie
                  ...Right, the strange 'blank post' bug on this forum cropped up again, so I'll try again:


                  So you have the Feet and Inches stored?
                  If so, here's how you can convert them to millimeters.
                  I'll pretend your two variables so far are called vHeightFeet and
                  vHeightInches, so change my code to suit what you've actually called them.
                  [code=vb]
                  Dim vHeightmm As Double
                  'We prepared a new variable in which to hold the converted length in mm

                  vHeightmm = (vHeightFeet + (vHeightInches/12)) * 304.8
                  'We just converted Feet+Inches into mm and stored it in the vHeightmm variable
                  [/code]

                  EXPLANATION:
                  Kadghar said that 1ft = 304.8mm
                  So we want to know how many feet and inches there are, in feet only.
                  Since there are 12 inches in a foot, if we divide the inches by 12, we get that equivalent length in feet (i.e. a decimal value less than 1).
                  This, plus the number of feet, equals the number of feet 'in decimal'.

                  Example: 1 foot 6 inches
                  6 inches divided by 12 = 0.5 feet
                  1 foot + 0.5 feet = 1.5 feet = 1 foot 6 inches 'in decimal'

                  Then we multiply this final value - 1.5 - by 304.8 to convert it to milimeters, and store it in variable vHeightmm.
                  This variable is declared as a 'Double' data type, meaning a number which can get very big, and have very accurate decimal points.



                  when i do that all it gives me back is the numbers that i input!
                  here is the snippet of code that i have wrote
                  [CODE=vbnet]
                  Console.WriteLi ne("Enter your height in feet")
                  vheightfeet = Convert.ToDoubl e(Console.ReadL ine())

                  Console.WriteLi ne("Enter your inches from your height")
                  vheightinches = Convert.ToDoubl e(Console.ReadL ine())

                  vheightmm = (vheightfeet + (vheightinches / 12)) * 304.8
                  Console.WriteLi ne(vheightfeet & " " & vheightinches)[/CODE]

                  Comment

                  • kadghar
                    Recognized Expert Top Contributor
                    • Apr 2007
                    • 1302

                    #10
                    Originally posted by cdm2883
                    when i do that all it gives me back is the numbers that i input!
                    here is the snippet of code that i have wrote

                    Console.WriteLi ne("Enter your height in feet")
                    vheightfeet = Convert.ToDoubl e(Console.ReadL ine())

                    Console.WriteLi ne("Enter your inches from your height")
                    vheightinches = Convert.ToDoubl e(Console.ReadL ine())

                    vheightmm = (vheightfeet + (vheightinches / 12)) * 304.8
                    Console.WriteLi ne(vheightfeet & " " & vheightinches)
                    Try
                    Console.WriteLi ne((vheightfeet + vheightinches/12) *304.8 & " mm")

                    Hope that helps

                    Comment

                    • cdm2883
                      New Member
                      • Sep 2007
                      • 53

                      #11
                      Originally posted by kadghar
                      Try
                      Console.WriteLi ne((vheightfeet + vheightinches/12) *304.8 & " mm")

                      Hope that helps
                      i keep getting a InnerException now when i do that

                      Comment

                      • Killer42
                        Recognized Expert Expert
                        • Oct 2006
                        • 8429

                        #12
                        Originally posted by cdm2883
                        When I do that all it gives me back is the numbers that I input!
                        Well, of course it does - you told it to. :) Your last line probably should be something like...[CODE=vbnet]Console.WriteLi ne(vheightmm & " mm")[/CODE]

                        Comment

                        • kadghar
                          Recognized Expert Top Contributor
                          • Apr 2007
                          • 1302

                          #13
                          Originally posted by cdm2883
                          i keep getting a InnerException now when i do that
                          have you tried this?

                          dim vheightmm as double
                          vheightmm = (vheightfeet + (vheightinches / 12)) * 304.8
                          Console.WriteLi ne(vheightmm)

                          Comment

                          • Killer42
                            Recognized Expert Expert
                            • Oct 2006
                            • 8429

                            #14
                            Originally posted by Robbie
                            ...Right, the strange 'blank post' bug on this forum cropped up again, so I'll try again:
                            I tried editing your post, and it looks as though the problem appears because you failed to close your CODE tag. Which is odd, because when I accidentally did the same thing just now, it just didn't bother with the colour-coding and so on. It seems to be playing favourites.

                            Comment

                            • cdm2883
                              New Member
                              • Sep 2007
                              • 53

                              #15
                              Originally posted by kadghar
                              have you tried this?

                              dim vheightmm as double
                              vheightmm = (vheightfeet + (vheightinches / 12)) * 304.8
                              Console.WriteLi ne(vheightmm)


                              yes thank you, that worked!
                              i am sure i will be back with more question! about diffrent things

                              Comment

                              Working...