< Public Function ConvertFromSafeText (OneLine As String) As String (?)

Comments

'------------------------------------------------------------------------- 'Converts a 'Safe' string to normal text ' eg. "MyNewFile_Version_1" would become "My New File Version 1" '-------------------------------------------------------------------------

Public Function ConvertFromSafeText (OneLine As String) As String


    Dim i As Integer
    Dim Char As String
    Dim strOutput As String
    
    'remove leading and trailing spaces
    OneLine = Trim(OneLine)
    
    If Len(OneLine) = 0 Then Exit Function
    
    For i = 1 To Len(OneLine)
        
        'Get single character
        Char = Mid(OneLine, i, 1)
    
        'capitalise first letter
        If i = 1 Then Char = UCase(Char)
    
        'If upper-case, denotes start of word
        If (i > 1) And (InStr(Alphabet(), Char) > 0) Then
        
            'Put space before
            strOutput = strOutput & " " & LCase(Char)
            
        Else
            
            'if underscore
            If Char = "_" Then
            
                'replace with space
                strOutput = strOutput & " "
                
            'anything else
            Else
                
                'use directly
                strOutput = strOutput & Char
            
            End If
            
        End If
    Next i
    
    ConvertFromSafeText = strOutput
End Function


Copying, Return to index