none
Extract inches RRS feed

  • Question

  • I have a cell that contains the height  as feet inch (5'7'') I need to convert this to inches. I'm able to get the feet and convert to inches but am struggling with getting the inch value.  Any help would be gladly appreciated.
    Friday, June 28, 2013 1:28 PM

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

    Friday, June 28, 2013 2:15 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) + inches

    MessageBox.Show("Total Inches: " & totalInches)


    micahlsmith

    Friday, June 28, 2013 2:23 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

    Friday, June 28, 2013 3:39 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

    Friday, June 28, 2013 2:15 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) + inches

    MessageBox.Show("Total Inches: " & totalInches)


    micahlsmith

    Friday, June 28, 2013 2:23 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

    Friday, June 28, 2013 3:39 PM