7,762
社区成员
发帖
与我相关
我的任务
分享
set reg = new regexp
reg.pattern = "[ ]+"
dst = reg.replace(src,",")
Option Explicit
Private Sub Command1_Click()
Dim cRichText() As String, cText() As String, S As String
Dim i As Integer, j As Integer
cRichText = Split(RichTextBox1.Text, vbCrLf)
For i = 0 To UBound(cRichText)
cText = Split(cRichText(i), " ")
If Len(cText(0)) <> 0 Then S = cText(0)
For j = 1 To UBound(cText)
If Len(cText(j)) <> 0 Then S = S & "," & cText(j)
Next
cRichText(i) = S
Next
RichTextBox1.Text = ""
For i = 0 To UBound(cRichText)
RichTextBox1.Text = RichTextBox1.Text & cRichText(i) & vbCrLf
Next
End Sub
Private Sub Form_Load()
RichTextBox1.FileName = "C:\66cn.txt" '加载文本内容
End Sub
Option Explicit
Private Sub Command1_Click()
Dim cRichText() As String, cText() As String, S As String
Dim i As Integer, j As Integer
cRichText = Split(RichTextBox1.Text, vbCrLf)
For i = 0 To UBound(cRichText)
cText = Split(cRichText(i), " ")
If Len(cText(0)) <> 0 Then S = cText(0)
For j = 1 To UBound(cText)
If Len(cText(j)) <> 0 Then S = S & "," & cText(j)
Next
cRichText(i) = S
Next
RichTextBox1.Text = ""
For i = 0 To UBound(cRichText)
RichTextBox1.Text = RichTextBox1.Text & cRichText(i) & vbCrLf
Next
End Sub
Private Sub Form_Load()
RichTextBox1.FileName = "C:\66cn.txt" '加载文本内容
End Sub
Private Sub Command1_Click()
Dim s As String
s = "66CN iv2 23.1238004649805113.3175715760020.01721744704992 :10.008385081103780.01530017937794 "
s = Trim(s) '去除尾空格
Do While InStr(s, " ") <> 0 '不管有多少个连续的空格,统统替换成一个空格
s = Replace(s, " ", " ")
Loop
s = Replace(s, " ", ",") & " " '空格替换成逗号,并加上尾空格
Debug.Print s
End Sub