473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

calculation height to millimeters

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 5012
cdm2883
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
kadghar
1,295 Expert 1GB
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
cdm2883
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
Killer42
8,435 Expert 8TB
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
cdm2883
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
Robbie
180 100+
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
Robbie
180 100+
...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
  1. Dim vHeightmm As Double
  2. 'We prepared a new variable in which to hold the converted length in mm
  3.  
  4. vHeightmm = (vHeightFeet + (vHeightInches/12)) * 304.8
  5. 'We just converted Feet+Inches into mm and stored it in the vHeightmm variable
  6.  
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
cdm2883
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
  1. Dim vHeightmm As Double
  2. 'We prepared a new variable in which to hold the converted length in mm
  3.  
  4. vHeightmm = (vHeightFeet + (vHeightInches/12)) * 304.8
  5. 'We just converted Feet+Inches into mm and stored it in the vHeightmm variable
  6.  
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
  1. Console.WriteLine("Enter your height in feet")
  2. vheightfeet = Convert.ToDouble(Console.ReadLine())
  3.  
  4. Console.WriteLine("Enter your inches from your height")
  5. vheightinches = Convert.ToDouble(Console.ReadLine())
  6.  
  7. vheightmm = (vheightfeet + (vheightinches / 12)) * 304.8
  8. Console.WriteLine(vheightfeet & "  " & vheightinches)
Sep 12 '07 #9
kadghar
1,295 Expert 1GB
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
cdm2883
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
Killer42
8,435 Expert 8TB
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
  1. Console.WriteLine(vheightmm & "  mm")
Sep 13 '07 #12
kadghar
1,295 Expert 1GB
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
Killer42
8,435 Expert 8TB
...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
cdm2883
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
Robbie
180 100+
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
Killer42
8,435 Expert 8TB
... 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

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: maceo | last post by:
I have some code that extracts the data from a table and performs a calculation (total time) on one of the columns. Here is the code: <?php /* Database connection */
5
by: Gas | last post by:
I am new to C#, I want to perfoem a calculation and I have a weird out come from the app. Here is the code double percentage = 0; percentage = ctrl1.Height / (ctrl1.Height+ ctrl2.Height) ...
1
by: Gas | last post by:
I am new to C#, I want to perfoem a calculation and I have a weird out come from the app. Here is the code double percentage = 0; percentage = ctrl1.Height / (ctrl1.Height+ ctrl2.Height) ...
7
by: GD1 | last post by:
Dear developers, is there any way I can calculate the height in millimeters of a font at a certain size? Thank you in advance.
18
by: Erich Meier | last post by:
Hello there, is there any way to set the size of images or table cells in HTML not by pixels but by inches or in millimetres? The problem behind this is that you never know what kind of output...
10
by: dtmfcc | last post by:
My website is at www.simi-therapy.com My CSS is at http://www.simi-therapy.com/simitherapy-screen.css Question -- on the dark blue bar under the beach image, one change caused another...
6
by: zandiago | last post by:
#include <cstring> #include <iostream> #include <iomanip> #include <cmath> #include <fstream> #include <string> #include <ctime> using namespace std;
11
by: mrking | last post by:
Hi, First time in the Java section here. I have an HTML form and a PHP script to do a simple calculation but it has to take me to a different page for the results. The calculator is really...
2
by: Keith G Hicks | last post by:
I have the following code which runs fine Imports System.Drawing Partial Class _Default Inherits System.Web.UI.Page Protected Sub Button2_Click(ByVal sender As Object, ByVal e As...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.