31. januar 2003 - 20:05
Der er
1 kommentar
how do i save
Hi all. Im trying to learn to load txt from file i've saved. Here is my save code
Private Sub cmdsave_Click()
cd1.InitDir = "C:\ "
cd1.Filter = "all files(*.*)|*.*|text files(*.txt)|*.txt"
cd1.FilterIndex = 2
cd1.ShowSave
If Len(cd1.filename) < 1 Then
Exit Sub
End If
Dim filename As String
filename = cd1.filename
savefile cd1.filename, Text1.Text
Me.Caption = " saved file "
End Sub
I want to know how i load this(or something else) into my text box. If someone give me the code would be great
thanks
geiri
01. februar 2003 - 00:21
#1
Sub TextStreamTest
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fs, f, ts, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile("test1.txt")
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
While Not rs.eof Then
s = s & vbcrlf & ts.ReadLine
Wend
MsgBox s
ts.Close
End Sub
I haven't tested it, but something like that will work. Check msdn.microsoft.com for more info on the FileSystemObject - it's pretty easy to
use, when you learn the basics of it.