Results 1 to 10 of 10

Thread: Quick question - help with formatting a string..

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195

    Quick question - help with formatting a string..


  2. #2
    Junior Member
    Join Date
    May 2001
    Location
    England
    Posts
    21
    Use the VB built in function mid to grab any characters at any position, this of course is only any use if you know the characters you are looking for:
    Justice Always Prevails!

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195
    i have no clue how to use mid..

  4. #4
    Junior Member
    Join Date
    May 2001
    Location
    England
    Posts
    21
    Sorry about that, I hit the bloody enter key, the code would look something like this:


    Dim Somevariable As String
    Dim TargetVariable As String

    TargetVariable = "http://me.home.books.wam"

    SomeVariable = mid(TargetVariable,8,7)

    SomeVariable = "me.home"

    8 Being the start position
    7 Being the length of characters required

    Hope this helps,

    JohnC.
    Justice Always Prevails!

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195
    thanks.. would you know the code for this?

    There are 10 items in a listbox.. (list1)

    http://me.server.com/items/onepage
    http://me.server.com/items/another
    http://dir.me.server.com/items/onepage
    http://dir.me.server.com/items/onepage
    http://rd.me.server.com/items/yetanother
    http://sub.server.com/items/onepage
    http://help.me.server.com/items/onepage
    http://www.server.com/items/onepage

    I also have another listbox (list2)
    How can i add all the items to list2 that look like http://me.server.com/items/ANYTHINGHERE??


    I tried and tried, but my brain cant come up with the logic to do this

  6. #6
    Addicted Member stevess's Avatar
    Join Date
    May 2001
    Posts
    251
    You have to be more specific, we can't read minds (at least not at this distance)

    Do you want to eliminate all the similar home directories?

  7. #7
    demirc
    Guest
    As mentioned above you have to be more specific, but you might want to look up:

    InStr function or the Like operator.

  8. #8
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    I am with demirc.

  9. #9
    Member choochoo's Avatar
    Join Date
    Jun 2001
    Posts
    51
    yeah, youd want to use the InStr function to search the listbox...
    use for & next statements also

    for i = 0 to list.listcount - 1
    if instr(list.list(i), "me.server.com") then
    list2.additem list.list(i)
    end if
    next i

    something like that should work although youll have to change that for your own needs...

    im not sure if thats what you wanted but i decided to post it anyways.
    read up on the instr function and for, next statement to learn more about using it.

  10. #10
    hellswraith
    Guest
    Use the Like operator.

    Code:
    Dim strMainString as String
    Dim strSubString as String
    
    'Set strMainString equal to one of the list1 items here
    'Set strSubString equal to the substring that you want
    'to find in the strMainString
    
    'Use the * symbol for wild card example:
    strSubString = "http://me.server.com/items/" & "*"
    'That will allow it to match up with anything that has
    'the same path, even though they are different file names.
    
    If (strMainString Like strSubString) then
        'add strMainString to your 2nd list box
    End if
    Hope that helps, if you need more information about the Like operator, ask, and I will post what the MSDN library has on it.

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