Dim s$, ss$(), i%, k%ss = Split(Text1.Text, vbCrLf) k = UBound(ss) s = "": If ss(k) = "" Then k = k - 1 For i = 0 To k s = s & ss(i) If i <> k Then s = s & vbCrLf Next Text1.Text = s
应该是正解,但到最后一个空的时候,如何控制不让有回车呢 '去掉末尾空行 Dim fso, tf Set fso = CreateObject("Scripting.FileSystemObject") Set tf = fso.CreateTextFile("newfile123", True) For p = 0 To UBound(tx) tf.write tx(p) & vbCrLf Next tf.Close
我整个过程是这么写的,好像不对, '【进行文件空格和,号替换处理,空行进行处理] N = 0 Do While Not EOF(1) Line Input #1, s If s <> "" Then ReDim Preserve tx(N) s = Replace(s, " ", "") s = Replace(s, ",", "|") tx(N) = s N = N + 1 End If Loop Close #1Open "newfile" For Output As #2 Cls For p = 0 To UBound(tx) Print #2, tx(p) Next Close #2 '去掉末尾空行 Dim fso, tf Set fso = CreateObject("Scripting.FileSystemObject") Set tf = fso.CreateTextFile("newfile123", True) For p = 0 To UBound(tx) tf.write tx(p) & vbCrLf Next tf.Close
我已经搞定了 '去掉末尾空行 Dim fso, tf Set fso = CreateObject("Scripting.FileSystemObject") Set tf = fso.CreateTextFile("newfile", True) For p = 0 To UBound(tx) If p < UBound(tx) Then tf.write tx(p) & vbCrLf Else tf.write tx(p) End If Next tf.Close 可能不怎么科学,?请指导
123
2342
abcd
最后一个abcd下面的一个默认的空行,其实好像不是空行的这种,想把光标移动到abcd的d这里,请问,跪求
k = UBound(ss)
s = "": If ss(k) = "" Then k = k - 1
For i = 0 To k
s = s & ss(i)
If i <> k Then s = s & vbCrLf
Next
Text1.Text = s
没有看明白,我发现要重新写到print#,貌似最后一行都有空行,文本 ,怎么办呢
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.CreateTextFile("c:\test.txt", True)
tf.Write "abc" & vbcrlf & "12345"
tf.Close
print #1 "abc" & vbcrlf & "12345";
应该是正解,但到最后一个空的时候,如何控制不让有回车呢
'去掉末尾空行
Dim fso, tf
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.CreateTextFile("newfile123", True)
For p = 0 To UBound(tx)
tf.write tx(p) & vbCrLf
Next
tf.Close
'【进行文件空格和,号替换处理,空行进行处理]
N = 0
Do While Not EOF(1)
Line Input #1, s
If s <> "" Then
ReDim Preserve tx(N)
s = Replace(s, " ", "")
s = Replace(s, ",", "|")
tx(N) = s
N = N + 1
End If
Loop
Close #1Open "newfile" For Output As #2
Cls
For p = 0 To UBound(tx)
Print #2, tx(p)
Next
Close #2
'去掉末尾空行
Dim fso, tf
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.CreateTextFile("newfile123", True)
For p = 0 To UBound(tx)
tf.write tx(p) & vbCrLf
Next
tf.Close
'去掉末尾空行
Dim fso, tf
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.CreateTextFile("newfile", True)
For p = 0 To UBound(tx)
If p < UBound(tx) Then
tf.write tx(p) & vbCrLf
Else
tf.write tx(p)
End If
Next
tf.Close
可能不怎么科学,?请指导