0
두 개의 특수 문자 ","및 "_"이있는 정수 값이 포함 된 열이 있습니다. 예를 들어 1,10_2,2_3,3이 1102233과 같아야 이러한 문자를 제거하려고합니다. 미리 제안 해 주셔서 감사합니다.VB에서 특수 문자를 제거하는 코드
두 개의 특수 문자 ","및 "_"이있는 정수 값이 포함 된 열이 있습니다. 예를 들어 1,10_2,2_3,3이 1102233과 같아야 이러한 문자를 제거하려고합니다. 미리 제안 해 주셔서 감사합니다.VB에서 특수 문자를 제거하는 코드
이 기능은 실수가 아니지만 좋은 시작입니다.
Function trim(aStringToTrim As String, aElementToTrinm() As Variant) As String
Dim elementToTrim As Integer
Dim IndexInString As Integer
For elementToTrim = LBound(aElementToTrinm) To UBound(aElementToTrinm)
IndexInString = InStr(aStringToTrim, aElementToTrinm(elementToTrim))
Do While IndexInString > 0
aStringToTrim = Left(aStringToTrim, IndexInString - 1) & Right(aStringToTrim, Len(aStringToTrim) - IndexInString - Len(aElementToTrinm(elementToTrim)) + 1)
IndexInString = InStr(aStringToTrim, aElementToTrinm(elementToTrim))
Loop
Next
End Function
그것은이 같은 사용 될 수 있습니다
Sub main()
Dim myString As String
Dim caracterstoRemove As Variant
caracterstoRemove = Array(",", ".")
myString = "This, is. a, string, with. caracters to remove."
myString = trim(myString, caracterstoRemove)
End Sub
이 질문은 답이 여기있다 : http://stackoverflow.com/questions/15723672/how-to-remove-all-non-alphanumeric -characters-from-a-string-except-period-and-sp – hnk