+ Reply to Thread
Results 1 to 3 of 3

Another very difficult question; sorry!

  1. #1
    Rob Hargreaves
    Guest

    Another very difficult question; sorry!

    I have a string as below

    SBR_1_Ammonia,SBR_2_MLSS,SBR_4_Ammonia,SBR_3_Ammonia,SBR_1_MLSS,SBR_4_MLSS,SBR_2_Ammonia,SBR_3_MLSS

    I need to get the computer to categorise and order the string with no help
    from an inteligent human!

    We all know through study of the string that we have 2 categories

    -Ammonia

    -MLSS

    and we can see there are 4 in each category in the dtring above, we find it
    easy because they are all numbered although in the worng order and they are
    all the entries in eac category are the same other than a number mid string.

    Is it possible to parse the string into 2 strings - 1 for each category and
    order them based on their percentage match of characters the fact that the
    remaining % of any string which doesnt match will be a number which can be
    used to re order.

    For example - the 2 strings will look like so -

    SBR_1_Ammonia,SBR_2_Ammonia,SBR_3_Ammonia,SBR_4_Ammonia

    &

    SBR_1_MLSS,SBR_2_MLSS,SBR_3_MLSS,SBR_4_MLSS

    Thanks for your suggestions. Sorry for keeping asking these mind boglers!

    Rob




  2. #2
    Nigel
    Guest

    Re: Another very difficult question; sorry!

    Hi Rob
    You can parse the string looking for and counting the occurrences of any
    string. However in this case I presume you do not know what the string(s)
    are or do you ? If you do then the procedure is straightforward - please
    post what the position is.

    --
    Cheers
    Nigel



    "Rob Hargreaves" <nrgsav@REM_Thistiscali.co.uk> wrote in message
    news:[email protected]...
    > I have a string as below
    >
    >

    SBR_1_Ammonia,SBR_2_MLSS,SBR_4_Ammonia,SBR_3_Ammonia,SBR_1_MLSS,SBR_4_MLSS,S
    BR_2_Ammonia,SBR_3_MLSS
    >
    > I need to get the computer to categorise and order the string with no help
    > from an inteligent human!
    >
    > We all know through study of the string that we have 2 categories
    >
    > -Ammonia
    >
    > -MLSS
    >
    > and we can see there are 4 in each category in the dtring above, we find

    it
    > easy because they are all numbered although in the worng order and they

    are
    > all the entries in eac category are the same other than a number mid

    string.
    >
    > Is it possible to parse the string into 2 strings - 1 for each category

    and
    > order them based on their percentage match of characters the fact that the
    > remaining % of any string which doesnt match will be a number which can be
    > used to re order.
    >
    > For example - the 2 strings will look like so -
    >
    > SBR_1_Ammonia,SBR_2_Ammonia,SBR_3_Ammonia,SBR_4_Ammonia
    >
    > &
    >
    > SBR_1_MLSS,SBR_2_MLSS,SBR_3_MLSS,SBR_4_MLSS
    >
    > Thanks for your suggestions. Sorry for keeping asking these mind boglers!
    >
    > Rob
    >
    >
    >




  3. #3
    Tom Ogilvy
    Guest

    Re: Another very difficult question; sorry!

    Sub AA()
    Dim v() As String, sStr2 as String
    Dim sStr As String, sStr1 as String
    Dim i As Long, j As Long, Swap1 as String
    Dim k As Long, sChr As String
    sStr = "SBR_1_Ammonia,SBR_2_MLSS,SBR_4_Ammonia," _
    & "SBR_3_Ammonia,SBR_1_MLSS,SBR_4_MLSS,SBR_2_" _
    & "Ammonia,SBR_3_MLSS"
    k = Len(sStr) - Len(Application.Substitute(sStr, ",", ""))
    ReDim v(0 To k + 1)
    j = 0
    For i = 1 To Len(sStr)
    sChr = Mid(sStr, i, 1)
    If sChr = "," Then
    j = j + 1
    Else
    v(j) = v(j) & sChr
    End If
    Next

    For i = 1 To j - 1
    For k = i + 1 To j
    If v(i) > v(k) Then
    Swap1 = v(i)
    v(i) = v(k)
    v(k) = Swap1
    End If
    Next k
    Next i
    For i = 0 To j
    If i Mod 2 = 0 Then
    sStr1 = sStr1 & "," & v(i)
    Else
    sStr2 = sStr2 & "," & v(i)
    End If
    Next
    sStr1 = Right(sStr1, Len(sStr1) - 1)
    sStr2 = Right(sStr2, Len(sStr2) - 1)
    MsgBox sStr1 & vbNewLine & sStr2

    End Sub

    --
    Regards,
    Tom Ogilvy

    "Rob Hargreaves" <nrgsav@REM_Thistiscali.co.uk> wrote in message
    news:[email protected]...
    > I have a string as below
    >
    >

    SBR_1_Ammonia,SBR_2_MLSS,SBR_4_Ammonia,SBR_3_Ammonia,SBR_1_MLSS,SBR_4_MLSS,S
    BR_2_Ammonia,SBR_3_MLSS
    >
    > I need to get the computer to categorise and order the string with no help
    > from an inteligent human!
    >
    > We all know through study of the string that we have 2 categories
    >
    > -Ammonia
    >
    > -MLSS
    >
    > and we can see there are 4 in each category in the dtring above, we find

    it
    > easy because they are all numbered although in the worng order and they

    are
    > all the entries in eac category are the same other than a number mid

    string.
    >
    > Is it possible to parse the string into 2 strings - 1 for each category

    and
    > order them based on their percentage match of characters the fact that the
    > remaining % of any string which doesnt match will be a number which can be
    > used to re order.
    >
    > For example - the 2 strings will look like so -
    >
    > SBR_1_Ammonia,SBR_2_Ammonia,SBR_3_Ammonia,SBR_4_Ammonia
    >
    > &
    >
    > SBR_1_MLSS,SBR_2_MLSS,SBR_3_MLSS,SBR_4_MLSS
    >
    > Thanks for your suggestions. Sorry for keeping asking these mind boglers!
    >
    > Rob
    >
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1