VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



String Cleaner : keep only digit, only Ucases ,only Lowercases, only digit and Ucase, Ucase and dig

by gilles manouvrier (3 Submissions)
Category: String Manipulation
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Thu 21st December 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

String Cleaner : keep only digit, only Ucases ,only Lowercases, only digit and Ucase, Ucase and digit, etc...

Rate String Cleaner : keep only digit, only Ucases ,only Lowercases, only digit and Ucase, Ucase and dig



You can replace forbidden chars by another :)
Public Function OnlyChars(ByVal txt As String, ByVal Uchars As Boolean, ByVal Lchars As Boolean, ByVal Digits As Boolean, Optional Remplacement As String) As String
Dim h As Long
Dim tempon As String

For h = 1 To Len(txt)
    num = Asc(Mid$(txt, h, 1))
    'suppression des uchars
    If Uchars Then
        If num >= 65 And num <= 90 Then
            tempon = tempon & Mid$(txt, h, 1)
        Else
            tempon = tempon & Remplacement
        End If
     
    End If
    
    If Lchars Then
        If num >= 97 And num <= 122 Then
        tempon = tempon & Mid$(txt, h, 1)
        Else
        tempon = tempon & Remplacement
            
        End If
    
    End If
    
    If Digits Then
        If num >= 48 And num <= 57 Then
            tempon = tempon & Mid$(txt, h, 1)
        
        Else
        tempon = tempon & Remplacement
            
        End If
    
    End If
   'If Uchars And Lchars And Digits Then tempon = tempon & Mid$(txt, h, 1)
Next
OnlyChars = tempon


End Function



Download this snippet    Add to My Saved Code

String Cleaner : keep only digit, only Ucases ,only Lowercases, only digit and Ucase, Ucase and dig Comments

No comments have been posted about String Cleaner : keep only digit, only Ucases ,only Lowercases, only digit and Ucase, Ucase and dig. Why not be the first to post a comment about String Cleaner : keep only digit, only Ucases ,only Lowercases, only digit and Ucase, Ucase and dig.

Post your comment

Subject:
Message:
0/1000 characters