...以外的所有全角半角字符文字字母都替换成逗号 ,
发布网友
发布时间:2024-10-20 20:58
我来回答
共1个回答
热心网友
时间:2024-11-17 07:45
'说明:Text1.Text为原文本,Text2.Text为输出后文本(写的比较乱,呵呵)
Private Sub Command1_Click()
Dim i As Long
Dim strResult As String
Text1.Text = "127,14,,,25,312,35,41他们2,42,44,47" & vbCrLf & _
"123,128,129,11,15,212,21,.23,27,36" & vbCrLf & _
"122,123,21,23,。15,18,19,33,37," & vbCrLf & _
"122,123,你好14,15,16,17,26,38,39,42," & vbCrLf & _
"12.9,11,13,19,27,312,34,【35,38,45,"
For i = 1 To Len(Text1.Text)
If Mid(Text1.Text, i, 2) = vbCrLf Then
strResult = strResult & vbCrLf
ElseIf Not IsNumeric(Mid(Text1.Text, i, 1)) And Right(strResult, 2) <> vbCrLf Then
strResult = strResult & ","
Else
strResult = strResult & Mid(Text1.Text, i, 1)
End If
Next
If Len(strResult) > 1 Then strResult = Mid$(strResult, 2)
If Right(strResult, 1) = "," Then strResult = Left(strResult, Len(strResult) - 1)
Text2.Text = strResult
Debug.Print strResult
End Sub