Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2003
    Location
    India
    Posts
    55

    Wink Unanswered: Splitting String

    Hi folks

    Is there any method to split a string into equal no sub strings using a single function.

    There is a function called Split in Access but dont know how to use it.

    There is no delimiter in the string.

    Any Eurekas

    Thanx in advance
    Sree

  2. #2
    Join Date
    Aug 2003
    Posts
    106
    In a fairly manual way, could you use the Mid function?

    MID(myString, StartCharNum, LengthCharNum)

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

    Re: Splitting String

    Originally posted by sreeraj
    Hi folks

    Is there any method to split a string into equal no sub strings using a single function.

    There is a function called Split in Access but dont know how to use it.

    There is no delimiter in the string.

    Any Eurekas

    Thanx in advance
    I haven't seen such built in function called split in Access, but you can make your own using the MID$ function in a loop for the LENGTH of the whole string

  4. #4
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Smile Re: Splitting String

    Originally posted by sreeraj
    Hi folks

    Is there any method to split a string into equal no sub strings using a single function.

    There is a function called Split in Access but dont know how to use it.

    There is no delimiter in the string.

    Any Eurekas

    Thanx in advance
    This is just an idea. It includes all the spaces in the string also.
    I used a listbox to add the items to to confirm that I was getting what I wanted

    Here it is:

    Private Sub ck1_Click()
    Dim str1 As String, col1 As New Collection, x As Integer, intSize As Integer
    Dim strWord As String, varItem As Variant, intOrig As Integer
    str1 = "This is a test to see how to split a string into smaller strings of equal parts"
    intSize = InputBox("Enter the grouping number", , 2)
    intOrig = Len(str1)
    lst1.RowSource = ""
    For x = 1 To intOrig
    If x Mod intSize = 0 Then
    strWord = Left(str1, intSize)
    str1 = Right(str1, intOrig - x)
    col1.Add strWord
    End If

    If Len(str1) < intSize Then
    col1.Add str1
    Exit For
    End If

    Next

    For Each varItem In col1
    lst1.RowSourceType = "Value List"
    lst1.AddItem varItem
    Next

    End Sub

  5. #5
    Join Date
    Oct 2003
    Location
    India
    Posts
    55

    Cool Split

    Hi guys,

    The Split function is VBA String function.But it doesnt suit my need becs it requires a delimiter in string to split it into sub strings.
    it Splits the string into an array .

    Syntax is

    Dim Arr(100) as Variant

    Str="ADSF ASDF ASDF ASDF ADF ASDF"

    arr=split(str," ")

    here it splits the string to 6 pieces taking space as delimiter.

    thanx for the Code .
    Sree

Posting Permissions

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