可以。Private Sub Command1_Click() Dim x As String richtextbox1.Text = "" Open "c:\temp.txt" For Input As #1 Do While Not EOF(1) Line Input #1, x richtextbox1.Text = richtextbox1.Text & x & vbCrLf Loop Close #1 End Sub
Private Sub Command1_Click() Dim x x=split(richtextbox1.Text ,vbcrlf) Open "c:\temp.txt" For output As #1 for i=0 to ubound(x) print #1,,x(i) next Close #1 End Sub
不管有没有c:\temp.txt这个文件,VB都会报告找不到文件
不管有没有c:\temp.txt这个文件,VB都会报告找不到文件,为什么?Open CommonDialog1.filename For output As #1 为什么也提示找不到文件?
把文本文件内容读取TextBox: Dim TempFile As Long Dim LoadBytes() As ByteTempFile=FreeFile Open 文件名 For Binary As #TempFile Redim LoadBytes(1 To Lof(TempFile)) As Byte Get #TempFile,,LoadBytes Close TempFileText1.Text=StrConv(LoadBytes,vbUniCode)把TextBox内容写入文本文件: Dim TempFile As Long Dim SaveBytes() As ByteSaveBytes=StrConv(Text1.Text,vbFromUniCode)TempFile=FreeFile Open 文件名 For Binary As #TempFile Put #TempFile,,SaveBytes Close TempFile
这个控件可以一行一行的读写吗?各位大哥请明示,我急用.
Dim x As String
richtextbox1.Text = ""
Open "c:\temp.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, x
richtextbox1.Text = richtextbox1.Text & x & vbCrLf
Loop
Close #1
End Sub
Dim x
x=split(richtextbox1.Text ,vbcrlf)
Open "c:\temp.txt" For output As #1
for i=0 to ubound(x)
print #1,,x(i)
next
Close #1
End Sub
为什么也提示找不到文件?
Dim TempFile As Long
Dim LoadBytes() As ByteTempFile=FreeFile
Open 文件名 For Binary As #TempFile
Redim LoadBytes(1 To Lof(TempFile)) As Byte
Get #TempFile,,LoadBytes
Close TempFileText1.Text=StrConv(LoadBytes,vbUniCode)把TextBox内容写入文本文件:
Dim TempFile As Long
Dim SaveBytes() As ByteSaveBytes=StrConv(Text1.Text,vbFromUniCode)TempFile=FreeFile
Open 文件名 For Binary As #TempFile
Put #TempFile,,SaveBytes
Close TempFile