have to take the height of a person and calculate it into millimeters how do i go about doing that?!
calculation height to millimeters
Collapse
X
-
do you mean the height in feet??Originally posted by cdm2883have to take the height of a person and calculate it into millimeters how do i go about doing that?!
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
HTHComment
-
Originally posted by kadghardo 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 applicationComment
-
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.Originally posted by cdm2883doing the code in a console application
And what version of VB are you using?Comment
-
Originally posted by Killer42Can 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
-
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
-
...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
-
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
-
TryOriginally posted by cdm2883when 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)
Console.WriteLi ne((vheightfeet + vheightinches/12) *304.8 & " mm")
Hope that helpsComment
-
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]Originally posted by cdm2883When I do that all it gives me back is the numbers that I input!Comment
-
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.Originally posted by Robbie...Right, the strange 'blank post' bug on this forum cropped up again, so I'll try again:Comment
Comment