dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: I need to get what is between the "-" and the "x" 12.450X5.65-13.476x12.89

  1. #1
    Join Date
    Feb 2015
    Posts
    2

    I need to get what is between the "-" and the "x" 12.450X5.65-13.476x12.89

    12.450X5.65-13.476x12.89

    I need the 13.476 out of the above string


    the data look like this

    23.5625X11.375-11.125x19.5625
    5.625X17.25-2.875x14.5
    23.75X17.25-12.5x19

  2. #2
    Join Date
    Feb 2015
    Posts
    2

    Re: I need to get what is between the "-" and the "x" 12.450X5.65-13.476x12.89

    This is what I have I just can't get it to come out right
    <code>
    If instr(Trim({Flat_panel1.jmaPartShortDescription}), "-") <> 0 THEN
    If instr(Trim({Flat_panel1.jmaPartShortDescription}), "x") <> 0 Then
    startPos1 = instr(Trim({Flat_panel1.jmaPartShortDescription}), "x") - 1
    Stileandrail = right(Trim({Flat_panel1.jmaPartShortDescription}),startPos1)
    Else
    Stileandrail = Trim({Flat_panel1.jmaPartShortDescription})
    End IF

    xposition = instr(Stileandrail, "x")
    startpos2 = len(Stileandrail) - xposition
    formula = Right(Stileandrail,startpos2)
    </code>

  3. #3
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,764

    Re: I need to get what is between the "-" and the "x" 12.450X5.65-13.476x12.89

    I'm not a crystal expert, but why not use mid() to extract the required info. Something along these lines (not tested and not complete)
    Code:
    str1 = instr({Flat_panel1.jmaPartShortDescription}, "-")
    str2 = instr({Flat_panel1.jmaPartShortDescription}, "x")
    
    if str1<> 0 then
        if str2 <> 0 then
           number = trim(mid({Flat_panel1.jmaPartShortDescription}, str1 + 1, str2 - str1 - 1))
        else
           number = trim(mid({Flat_panel1.jmaPartShortDescription}, str1 + 1))
    ....
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.2.2)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)