Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Posts
    3

    Unanswered: Trim or Substring for a tree?

    I am very new to this, please help.......
    I have a table called Levels. In the table I have columns I need to complare. The first is Level_id which is an INT datatype. The second column is my problem. It is called Tree as is a Text data type.

    Level_id

  2. #2
    Join Date
    Oct 2003
    Posts
    3

    Re: Trim or Substring for a tree?

    I am very new to all this, please help.......
    I have a table called Levels. In the table I have columns I need to complare. The first is Level_id which is an INT datatype. The second column is my problem. It is called Tree as is a Text data type.

    Level_id Tree
    111 /
    112 /111/
    113 /111/112/
    1114 /
    1115 /1114/

    I only need to extract the first set of numbers so I can identify the heirarchy. I have tried the Trim and Substring, but neither seem appropriate as the 111 could be 1111. Is there a way to extract variable lengths with Substring?

    Any help is appriciated....

  3. #3
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    I thing you must use two function like this sample:
    posRecorrido = InStr(1, nodBoss.Key, "R", vbBinaryCompare)
    ClaveCategoria = Mid(nodBoss.Key, 2, (posRecorrido - 2))
    the first function tell you were is the position of "R" the second function
    extract character.
    This can help you, see the use of that function in the help of Access
    Saludos
    Norberto

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Wink

    You can use a function like that
    NOTE: you must have a global array called glob_aSplits defined like that:
    '''''''''''''''''''''''''''''''''
    Global glob_aSplits() As String'when Spliting a string will be stored here
    '''''''''''''''''''''''''''''''''''''''''''


    Function splitString(thisString, Separator)
    Dim aSplited() As String
    Dim i As Integer, j As Integer, k As Integer
    Dim SeparatorPos As Integer, FieldSeparatorPos As Integer
    Dim lfound As Boolean

    lfound = True
    i = 1
    j = 1
    Do While lfound
    SeparatorPos = InStr(j, thisString, Separator)
    If SeparatorPos <= 0 Then
    ReDim Preserve aSplited(i)
    aSplited(i) = Mid(thisString, j, Len(thisString))
    ReDim Preserve glob_aSplits(i)
    glob_aSplits(i) = aSplited(i)
    Debug.Print glob_aSplits(i)
    lfound = False
    Else
    ReDim Preserve aSplited(i)
    aSplited(i) = Mid(thisString, j, SeparatorPos - j)
    ReDim Preserve glob_aSplits(i)
    glob_aSplits(i) = aSplited(i) ' filling the global array glob_aSplits

    ' Debug.Print glob_aSplits(i)

    i = i + 1
    j = SeparatorPos + 1
    End If
    Loop


    End Function

Posting Permissions

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