# Need help converting inches-yards-feet-inches

Page 1 of 1

## 4 Replies - 9573 Views - Last Post: 17 January 2009 - 04:32 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=81400&amp;s=df992d2acfcbeeb1ddfbe8bdc2ed0807&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 bkinley

Reputation: 0
• Posts: 3
• Joined: 17-January 09

# Need help converting inches-yards-feet-inches

Posted 17 January 2009 - 01:08 PM

I am new to VB and I have a simple assignment to where I need to input inches and the output will display those inches in yards, feet and inches. I am having problems with the math equation to get this too happen. Below is the code that I have thus far and thanks in advance for the help.

``` Dim inches As Integer
Dim yards As Integer
Dim feet As Integer
Dim total As Integer

Console.Write("Enter a distance in inches: ")

total = inches / 36

Console.WriteLine("The distance is " & total & " yards, " & total & " feet, " & total & " inches ")

```

Is This A Good Question/Topic? 0

## Replies To: Need help converting inches-yards-feet-inches

### #2 n8wxs

• --... ...-- -.. . -. ---.. .-- -..- ...

Reputation: 972
• Posts: 3,878
• Joined: 07-January 08

## Re: Need help converting inches-yards-feet-inches

Posted 17 January 2009 - 01:47 PM

How 'bout:
```Dim inches As Single
Dim yards As Single
Dim feet As Single
Dim total As Single

Console.Write("Enter a distance in inches: ")

feet	= inches / 12
yards  = inches / 36

total   = inches / 36

Console.WriteLine("The distance is " & yards  & " yards, " & feet   & " feet, " & inches & " inches ")

```

### #3 bkinley

Reputation: 0
• Posts: 3
• Joined: 17-January 09

## Re: Need help converting inches-yards-feet-inches

Posted 17 January 2009 - 02:07 PM

n8wxs, on 17 Jan, 2009 - 12:47 PM, said:

How 'bout:
```Dim inches As Single
Dim yards As Single
Dim feet As Single
Dim total As Single

Console.Write("Enter a distance in inches: ")

feet	= inches / 12
yards  = inches / 36

total   = inches / 36

Console.WriteLine("The distance is " & yards  & " yards, " & feet   & " feet, " & inches & " inches ")

```

Thanks for the info but it is not working like I think it is suppose to work. Let me give you an example of the output I am trying to get.

If I input 140 inches, my output should read 3 yard, 2 feet, and 8 inches.

I know I have to use the "MOD" code in order to get the remainder but I have having trouble getting the math equations to work.

Thanks

### #4 bkinley

Reputation: 0
• Posts: 3
• Joined: 17-January 09

## Re: Need help converting inches-yards-feet-inches

Posted 17 January 2009 - 03:42 PM

Below is my new code but I have problems with the math adding up. The total number is not adding up to the total inches that I input.

Example:
I input 140 inches and the math gives me 3 yards, 2 feet, and 2 inches.

I know this is not correct. Is there an easier way to write out the math equation?

```Module Module1

Sub Main()
Dim inches As Single
Dim yards As Integer
Dim feet As Single
Dim total As Single

Console.Write("Enter a distance in inches: ")

yards = inches \ 36
feet = inches Mod yards
total = feet Mod inches

Console.WriteLine("The distance is " & yards & " yards, " & feet & " feet, " & total & " inches ")

End Sub

End Module

```

### #5 n8wxs

• --... ...-- -.. . -. ---.. .-- -..- ...

Reputation: 972
• Posts: 3,878
• Joined: 07-January 08

## Re: Need help converting inches-yards-feet-inches

Posted 17 January 2009 - 04:32 PM

```		Dim inches As Integer = 140
Dim yards As Integer
Dim feet As Integer

yards = inches \ 36

inches = inches - yards * 36

feet = inches \ 12

inches = inches - feet * 12

```