_ String Functions _
Includes many common useful string functions. Reverse string, Remove extra spaces, Delimit string, Alternating caps, Proper case, and Count number of occurances of a string in a string. Vote if you like it!
AI
ملخص الذكاء الاصطناعي: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
كود المصدر
Public Function ReverseString(TheString As String) As String
ReverseString = ""
For i = 0 To Len(TheString) - 1
ReverseString = ReverseString & Mid(TheString, Len(TheString) - i, 1)
Next i
End Function
Public Function RemoveExtraSpaces(TheString As String) As String
Dim LastChar As String
Dim NextChar As String
LastChar = Left(TheString, 1)
RemoveExtraSpaces = LastChar
For i = 2 To Len(TheString)
NextChar = Mid(TheString, i, 1)
If NextChar = " " And LastChar = " " Then
Else
RemoveExtraSpaces = RemoveExtraSpaces & NextChar
End If
LastChar = NextChar
Next i
End Function
Public Function DelimitString(TheString As String, Delimiter As String) As String
DelimitString = ""
For i = 1 To Len(TheString)
If i <> Len(TheString) Then
DelimitString = DelimitString & Mid(TheString, i, 1) & Delimiter
Else
DelimitString = DelimitString & Mid(TheString, i, 1)
End If
Next i
End Function
Public Function AltCaps(TheString As String, Optional StartWithFirstCharacter As Boolean = True) As String
Dim LastCap As Boolean
AltCaps = ""
If StartWithFirstCharacter = False Then LastCap = True
For i = 1 To Len(TheString)
If LastCap = False Then
AltCaps = AltCaps & UCase(Mid(TheString, i, 1))
LastCap = True
Else
AltCaps = AltCaps & LCase(Mid(TheString, i, 1))
LastCap = False
End If
Next i
End Function
Public Function Propercase(TheString As String) As String
Propercase = UCase(Left(TheString, 1))
For i = 2 To Len(TheString)
If Mid(TheString, i - 1, 1) = " " Then
Propercase = Propercase & UCase(Mid(TheString, i, 1))
Else
Propercase = Propercase & LCase(Mid(TheString, i, 1))
End If
Next i
End Function
Public Function CountCharacters(TheString As String, CharactersToCheckFor As String) As Integer
Dim Char As String
Dim ReturnAgain As Boolean
CountCharacters = 0
For i = 1 To Len(TheString)
If i < (Len(TheString) + 1 - Len(CharactersToCheckFor)) Then
Char = Mid(TheString, i, Len(CharactersToCheckFor))
ReturnAgain = True
Else
Char = Mid(TheString, i)
ReturnAgain = False
End If
If Char = CharactersToCheckFor Then CountCharacters = CountCharacters + 1
If ReturnAgain = False Then GoTo NextPos
Next i
NextPos:
End Function
التعليقات الأصلية (3)
مسترجع من Wayback Machine