Enhance the Trim Function

Enhance the Trim Function

The Trim function has a serious shortcoming: It handles only space characters?not all the usual white spaces such as tabs, carriage returns, and line feeds. Instead of the standard Trim function, use my TrimAll function, which handles all white spaces. In fact, you can extend it to trim off any character by editing the assignment to the ToEliminate string variable:

 Public Function TrimAll(ToTrim As String) As String	Static ToEliminate As String	Dim Start As Long, Finish As Long	' Base condition test	If Len(ToTrim) = 0 Then		TrimAll = ""		Exit Function	End If	' Define the characters (once) that we want to trim off	If Len(ToEliminate) = 0 Then		ToEliminate = Chr(0) & Chr(8) & Chr(9) _			& Chr(10) & Chr(13) & Chr(32)	End If	' Find the beginning of nonblank string by checking  	' each char against a list of blank chars.	Start = 1	Do While Start <= Len(ToTrim)		If InStr(ToEliminate, Mid$(ToTrim, Start, 1)) Then			Start = Start + 1		Else			Exit Do		End If	Loop	' Find the end of nonblank string.	Finish = Len(ToTrim)	Do While Finish > 1		If InStr(ToEliminate, Mid$(ToTrim, Finish, 1)) Then				Finish = Finish - 1		Else			Exit Do		End If	Loop	If Start > Finish Then		' If the string is completely blank,		' Start will be greater than Finish.		TrimAll = ""		Exit Function	Else		' Trim out the real contents		TrimAll = Mid$(ToTrim, Start, Finish - Start + 1)	End IfEnd Function
Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved