Visual Basic Core Snippet Routines
TrimNull (api version)
          
                 
   Returns the string up to the trailing null, or the passed string if none. Uses VB's undocumented StrPtr() API.         
           Updated:   Monday December 26, 2011   
click to copy code:  


   Applies to:   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 Declare Function lstrlenW Lib "kernel32" _
  (ByVal lpString As Long) As Long
         
Private Function TrimNull(startstr As String) As String

   TrimNull = Left$(startstr, lstrlenW(StrPtr(startstr)))
   
End Function

 Calling Syntax
   somevar = TrimNull(somestring)

 Comments / Related
demo in use:   RegQueryValueEx: Identify Time Zones by Time Zone Bias   
Related:   TrimNull   

 
 

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