
April 25th, 2008, 07:06 AM
|
|
|
|
Remove tab from string
My code is a validation program and it removes all not valid characters by only keeping the valid ones. However tabs still stay! I've tried stripping them with Trim and replace functions but neither work. Help!
Code:
'tried to remove tab section
strTest1Orig1 = strTest1Orig
vbTab1 = vbTab & vbTab
strTest1Orig = Replace(strTest1Orig1, vbTab1, "")
ALL CODE excluding importing value
Code:
Public Sub PrcFormat_Tidy(strTest1, type1)
type1 = LCase(type1)
'removes invalid characters and makes all characters CAPS as per format requested
Dim strTest1Orig
strTest1Orig = strTest1
'###########
If type1 = "" Then ' check default
strValidChar = "abcdefghijklmnopqrstuvwxyz0123456789@ -'_"
Else
If type1 = "letter" Then
strValidChar = "abcdefghijklmnopqrstuvwxyz"
Else
If type1 = "number" Then ' check default
strValidChar = "0123456789"
End If
End If
End If
If Len(strValidChar) > 0 Then
'if there are valid characters
Counter2 = Len(strValidChar)
For Counter1 = 1 To Counter2
vRemove = Mid(strValidChar, Counter1, 1)
strTest1 = Replace(strTest1, vRemove, "")
Next Counter1
Else
End If
'#################
If Len(strTest1) > 0 Then
'need to remove a character
vCounter4 = Len(strTest1)
For Counter3 = 1 To Counter4
vRemove = Mid(strTest1, Counter3, 1)
'find the first character via the loop then loop and find second these characters
'come from the remaining characters after removing validate characters
strTest1Orig = Replace(strTest1Orig, strTest1, "")
Next Counter3
Else
End If
strTest1Orig1 = strTest1Orig
vbTab1 = vbTab & vbTab
strTest1Orig = Replace(strTest1Orig1, vbTab1, "")
strTest1Orig = UCase(strTest1Orig)
If Len(strTest1Orig) > 0 Then
strTest1 = strTest1Orig
Else
strTest1 = " "
End If
type1 = ""
End Sub
|