Answered by:
Extract inches
Question

Answers

string Size = string.Empty;
Size = "5\'7\"";//split the string to separate the feet from inches
string[] SplitStringValue = Size.Split('\'');
int feet = Convert.ToInt32(SplitStringValue[0]);//remove the slash and quote
string inchesString = SplitStringValue[1].Replace("\"", "");
int inches = Convert.ToInt32(inchesString);//every foot gives 12 inches. multiply out the feet, then add the remaining inches.
int totalInches = (feet * 12) + inches;MessageBox.Show("Total Inches: " + Convert.ToString(totalInches));
micahlsmith
 Marked as answer by Damon ZhengModerator Tuesday, July 2, 2013 1:35 PM

Dim Size As String = String.Empty
Size = "5'7"""'split the string to separate the feet from inches
Dim SplitStringValue() As String = Size.Split("'")
Dim feet As Integer = SplitStringValue(0)'Remove the quote
Dim inches As Integer = SplitStringValue(1).Replace("""", "")'every foot gives 12 inches. multiply out the feet, then add the remaining inches.
Dim totalInches As Integer = (feet * 12) + inchesMessageBox.Show("Total Inches: " & totalInches)
micahlsmith
 Marked as answer by Damon ZhengModerator Tuesday, July 2, 2013 1:35 PM

I don't know what format you're looking for so I'm adding options.
Cell formulas:
Cell A1 (Format Feet'Inches") is a must
Find single quote formula =FIND("'",A1,1)
Find double quote formula =FIND("""",A1,1)
Find feet formula =MID(A1,1,FIND("'",A1,1)1)
Find inches formula =MID(A1,FIND("'",A1,1) + 1,FIND("""",A1,1)3)
Calculate Total Inches =(MID(A1,1,FIND("'",A1,1)1) * 12) + MID(A1,FIND("'",A1,1) + 1,FIND("""",A1,1)3)
micahlsmith
 Marked as answer by Damon ZhengModerator Tuesday, July 2, 2013 1:35 PM
All replies

string Size = string.Empty;
Size = "5\'7\"";//split the string to separate the feet from inches
string[] SplitStringValue = Size.Split('\'');
int feet = Convert.ToInt32(SplitStringValue[0]);//remove the slash and quote
string inchesString = SplitStringValue[1].Replace("\"", "");
int inches = Convert.ToInt32(inchesString);//every foot gives 12 inches. multiply out the feet, then add the remaining inches.
int totalInches = (feet * 12) + inches;MessageBox.Show("Total Inches: " + Convert.ToString(totalInches));
micahlsmith
 Marked as answer by Damon ZhengModerator Tuesday, July 2, 2013 1:35 PM

Dim Size As String = String.Empty
Size = "5'7"""'split the string to separate the feet from inches
Dim SplitStringValue() As String = Size.Split("'")
Dim feet As Integer = SplitStringValue(0)'Remove the quote
Dim inches As Integer = SplitStringValue(1).Replace("""", "")'every foot gives 12 inches. multiply out the feet, then add the remaining inches.
Dim totalInches As Integer = (feet * 12) + inchesMessageBox.Show("Total Inches: " & totalInches)
micahlsmith
 Marked as answer by Damon ZhengModerator Tuesday, July 2, 2013 1:35 PM

I don't know what format you're looking for so I'm adding options.
Cell formulas:
Cell A1 (Format Feet'Inches") is a must
Find single quote formula =FIND("'",A1,1)
Find double quote formula =FIND("""",A1,1)
Find feet formula =MID(A1,1,FIND("'",A1,1)1)
Find inches formula =MID(A1,FIND("'",A1,1) + 1,FIND("""",A1,1)3)
Calculate Total Inches =(MID(A1,1,FIND("'",A1,1)1) * 12) + MID(A1,FIND("'",A1,1) + 1,FIND("""",A1,1)3)
micahlsmith
 Marked as answer by Damon ZhengModerator Tuesday, July 2, 2013 1:35 PM