Results 1 to 6 of 6

Thread: [RESOLVED] basic string help :(

  1. #1

    Thread Starter
    Lively Member feneck's Avatar
    Join Date
    Mar 2007
    Location
    Australia, Queensland, Gympie
    Posts
    85

    Resolved [RESOLVED] basic string help :(

    Ok, so i have done this:

    Text1.Selstart = Instr(Text1, "http://img.")

    This begins the start of the selection, however there isnt a Selend, only a Sellength!

    I need a way (because the length will always be random) to find the string ".jpg" and end the selection there.

    Its properly really easy but im finding this really hard

    thanks

    REMEMBER TO RATE

  2. #2
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: basic string help :(

    Truncate the trailing part first. Sellength would then be length of this string less length of leading characters you will also truncate.

  3. #3

    Thread Starter
    Lively Member feneck's Avatar
    Join Date
    Mar 2007
    Location
    Australia, Queensland, Gympie
    Posts
    85

    Re: basic string help :(

    Could you give me an example :$ im real bad with this string stuff, it really messes with my mind

    REMEMBER TO RATE

  4. #4
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Re: basic string help :(

    something like this maybe:

    Code:
    Dim val As Integer
    Text1.SelStart = 0
    pos = InStr(Text1.Text, ".jpg")
    val = Len(Mid(Text1.Text, 1, pos - 1))
    Text1.SelLength = val

  5. #5
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: basic string help :(

    My contribution, something like:
    Code:
    Private Const SEARCHFOR As String = "http://img."
    
    Private Sub Command1_Click()
    Dim intSelStart As Integer
    Dim intSelEnd As Integer
    Dim intSelLength As Integer
    Dim intSLen As Integer
    intSLen = Len(SEARCHFOR)
    intSelStart = InStr(Text1.Text, SEARCHFOR)
    intSelEnd = InStr(intSelStart + intSLen - 1, Text1.Text, ".jpg")
    Text1.SelStart = intSelStart - 1
    Text1.SelLength = intSelEnd + 3 - intSelStart + 1
    End Sub

  6. #6

    Thread Starter
    Lively Member feneck's Avatar
    Join Date
    Mar 2007
    Location
    Australia, Queensland, Gympie
    Posts
    85

    Re: [RESOLVED] basic string help :(

    thanks. that last one did it

    REMEMBER TO RATE

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