429,384 Members | 927 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,384 IT Pros & Developers. It's quick & easy.

# calculation height to millimeters

 P: 53 have to take the height of a person and calculate it into millimeters how do i go about doing that?! Sep 11 '07 #1
16 Replies

 P: 53 have to take the height of a person and calculate it into millimeters how do i go about doing that?! without using a msgbox. Sep 11 '07 #2

 Expert 100+ P: 1,295 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 Sep 11 '07 #3

 P: 53 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 Sep 11 '07 #4

 Expert 5K+ P: 8,434 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? Sep 12 '07 #5

 P: 53 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. Sep 12 '07 #6

 100+ P: 180 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. Sep 12 '07 #7

 100+ P: 180 ...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. Expand|Select|Wrap|Line Numbers 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. Sep 12 '07 #8

 P: 53 ...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. Expand|Select|Wrap|Line Numbers 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. 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 Expand|Select|Wrap|Line Numbers Console.WriteLine("Enter your height in feet") vheightfeet = Convert.ToDouble(Console.ReadLine())   Console.WriteLine("Enter your inches from your height") vheightinches = Convert.ToDouble(Console.ReadLine())   vheightmm = (vheightfeet + (vheightinches / 12)) * 304.8 Console.WriteLine(vheightfeet & "  " & vheightinches) Sep 12 '07 #9

 Expert 100+ P: 1,295 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.WriteLine("Enter your height in feet") vheightfeet = Convert.ToDouble(Console.ReadLine()) Console.WriteLine("Enter your inches from your height") vheightinches = Convert.ToDouble(Console.ReadLine()) vheightmm = (vheightfeet + (vheightinches / 12)) * 304.8 Console.WriteLine(vheightfeet & " " & vheightinches) Try Console.WriteLine((vheightfeet + vheightinches/12) *304.8 & " mm") Hope that helps Sep 12 '07 #10

 P: 53 Try Console.WriteLine((vheightfeet + vheightinches/12) *304.8 & " mm") Hope that helps i keep getting a InnerException now when i do that Sep 12 '07 #11

 Expert 5K+ P: 8,434 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... Expand|Select|Wrap|Line Numbers Console.WriteLine(vheightmm & "  mm") Sep 13 '07 #12

 Expert 100+ P: 1,295 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.WriteLine(vheightmm) Sep 13 '07 #13

 Expert 5K+ P: 8,434 ...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. Sep 13 '07 #14

 P: 53 have you tried this? dim vheightmm as double vheightmm = (vheightfeet + (vheightinches / 12)) * 304.8 Console.WriteLine(vheightmm) yes thank you, that worked! i am sure i will be back with more question! about diffrent things Sep 13 '07 #15

 100+ P: 180 Good to know you're able to get it to work in the end. =) 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. Ah! I didn't realize. But the thing which happened for you is the same thing which normally happens to me too - i.e. it just literally displaying the CODE tag, not formatting the code. Strange. =/ Sep 13 '07 #16

 Expert 5K+ P: 8,434 ... But the thing which happened for you is the same thing which normally happens to me too - i.e. it just literally displaying the CODE tag, not formatting the code. Strange. =/ I think it might have something to do with how close it is to the end of the message. Sep 13 '07 #17