Results 1 to 7 of 7

Thread: [RESOLVED] how to make list from a string

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2013
    Posts
    91

    Resolved [RESOLVED] how to make list from a string

    hi i was trying to make list from a string. but due to some condition i am not getting idea.

    i will get string randomly. ex:
    Code:
    strin=" jhdaj kjhdeiuyedhsjk kjkcszn opioqwhbhj ghgas gfcghsdavghsdhsadvghfsdh jhhjb jhk"

    i taken it as array. to make list and printing it simply.
    Code:
    dim wor() as string
    dim words as string
    wor=split(strin, " ")
    dim li as integer
    for li=lbound(wor) to ubound(wor)
    words=words & vbcrlf & li+1 & ". " & wor(li)
    next
    msgbox words
    it will simply print all but now condition is that if length is exceeds more then 170 then every 170 a new msgbox
    automatic appear with resuming serial wise.
    one more condition if length exceeds more then 170 and last word come half like last word is "neegita"
    msgbox output1:
    1. rahul
    2. ajay
    3. swati
    ....
    10. nee

    msgbox output2:
    gita
    11. sulekha
    12. heena
    ...

    then the last word come in another msgbox output

    10. neegita
    11. sulekha
    12. heena
    ...

    please help me
    Last edited by goodfather; Feb 13th, 2015 at 01:35 AM.

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,233

    Re: how to make list from a string

    Has anyone understood what he wants?

    How about you use real words/sentences (and not that gibberish), to show us what the problem is
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2013
    Posts
    91

    Re: how to make list from a string

    Quote Originally Posted by Zvoni View Post
    Has anyone understood what he wants?

    How about you use real words/sentences (and not that gibberish), to show us what the problem is
    bro as i said sentence are not fixed. it come randomly. its actually names like

    string="fedi john smith karl linda bony jacky..."


    not fixed string hope now u get me

  4. #4
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,890

    Re: how to make list from a string

    Then what is not working in the code you posted?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Apr 2013
    Posts
    91

    Re: how to make list from a string

    Quote Originally Posted by Arnoutdv View Post
    Then what is not working in the code you posted?
    I guess you didnt read all carefully. i said there is some condition bro


    1. every msgbox(list) length total should exceed 170.

    2. if the last word in last msgbox(list) contain half word then it automatically move to another msgbox(list)

  6. #6
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,890

    Re: how to make list from a string

    A sample "bro":
    Code:
    Private Sub Command1_Click()
      Dim sWords() As String
      Dim sList As String
      Dim sAdd As String
      Dim i As Long
      
      Const MAXLEN = 25
      
      sWords = Split("jhdaj kjh deiuy edhsjk kjkcszn opi oqwhbhj ghgas gfcgh sd avghsdh sadvgh fsdh jhhjb jhk", " ")
      sList = ""
      For i = LBound(sWords) To UBound(sWords)
        sAdd = CStr(i + 1) & ". " & sWords(i)
        If Len(sList) + Len(sAdd) > MAXLEN Then
          MsgBox sList
          sList = ""
        End If
        If Len(sList) = 0 Then
          sList = sAdd
        Else
          sList = sList & vbCrLf & sAdd
        End If
      Next
      If Len(sList) > 0 Then MsgBox sList
    
    End Sub

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Apr 2013
    Posts
    91

    Re: how to make list from a string

    Arnoutdv bro you are superb hat off to you. this what i wanted awesome.

Posting Permissions

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



Click Here to Expand Forum to Full Width