Results 1 to 3 of 3

Thread: [RESOLVED] (string manipulation) grabbing three characters from this link..

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    395

    Resolved [RESOLVED] (string manipulation) grabbing three characters from this link..

    http://myssite.com/BNV/1/007/
    http://myssite.com/NYT/1/008/
    http://myssite.com/IMH/1/017/
    http://myssite.com/HNG/1/051/
    http://myssite.com/ABD/1/047/
    http://myssite.com/ERR/1/202/
    http://myssite.com/VFG/1/017/


    How would I just retrieve "IMG" from the above link? I just want the three letters. The link format stays the same...

    Ive tried several Mid, Left and Right but I'm doing something wrong.

    Thanks!
    8 gigs/ram (hey why not)
    300 gig HD x2
    Windows XP 64

  2. #2
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: (string manipulation) grabbing three characters from this link..

    Is this what you mean?
    VB Code:
    1. Option Explicit
    2.  
    3. Private Function Get3Letters(URL As String) As String
    4.     Dim lonPos As Long, lonEnd As Long
    5.    
    6.     'Find .com/
    7.     lonPos = InStr(1, URL, ".com/", vbTextCompare)
    8.    
    9.     If lonPos > 0 Then
    10.         'find next /
    11.         lonPos = lonPos + 5
    12.        
    13.         lonEnd = InStr(lonPos, URL, "/")
    14.        
    15.         If lonEnd > 0 Then
    16.             Get3Letters = Mid$(URL, lonPos, (lonEnd - lonPos))
    17.         End If
    18.        
    19.     End If
    20.    
    21. End Function
    22.  
    23.  
    24. 'Test the function.
    25. Private Sub Form_Load()
    26.     'http://myssite.com/VFG/1/017/
    27.     Dim strTest As String
    28.    
    29.     strTest = "http://myssite.com/VFG/1/017/"
    30.    
    31.     MsgBox Get3Letters(strTest)
    32. End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    395

    Re: (string manipulation) grabbing three characters from this link..

    You are awesome and that was quick!

    Would you happen to have code to output a random number 10 - 50?

    Thank you thank you thank you!

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