Visual Basic Core Snippet Routines
StripDelimitedItem
          
                 
   Returns string up to the specified delimiter, reducing original string to enable removal of the next delimited item. Can be used in all VB versions - handy when Split() is not an option.          
           Updated:   Monday December 26, 2011   
click to copy code:  


   Applies to:   VB4-32, VB5, VB6   
OS restrictions:   None  
 Code Snippet
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright 1996-2011 VBnet/Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
'               applications, but you may not reproduce 
'               or publish this code on any web site,
'               online service, or distribute as source 
'               on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function StripDelimitedItem(startStrg As String, _
                                    delimiter As String) As String

  'take string separated by delimiter,
  'split off one item, and shorten
  'so next item is ready for removal
   Dim pos As Long
   
   pos = InStr(1, startStrg, delimiter)
   
   If pos Then

      StripDelimitedItem = Mid$(startStrg, 1, pos - 1)
      startStrg = Mid$(startStrg, pos + 1, Len(startStrg))
    
   Else
   
      StripDelimitedItem = startStrg
      startStrg = ""
      
   End If

End Function

 Calling Syntax
   somevar = StripDelimitedItem(somestring, delimiter)

 Comments / Related
demo in use:   GetNetworkParams: Obtain Domain Registering the Local Machine
Related:   TrimNull (api version)  

 
 

PayPal Link
Make payments with PayPal - it's fast, free and secure!

 
 
 
 

Copyright 1996-2011 VBnet and Randy Birch. All Rights Reserved.
Terms of Use  |  Your Privacy

 

Hit Counter