Link to home
Start Free TrialLog in
Avatar of tota79
tota79

asked on

New, Open, Save ?

hi , Experts
i wana to know how to make a new file , open and save file?
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

dim strFile as string
dim intFile as integer
dim strData as string

strFile = "C:\yourfile.txt"

'create a file
intFile = freefile
open strFile for output as #intFile
print #intfile, "yourdata"
close #intFile

'reading a file
intFile = freefile
open strFile for input as #intFile
while not eof(intFile)
  line input #intFile, strData    
wend
close #intFile

'delete a file
kill strFile

CHeers
Avatar of tota79
tota79

ASKER

i have a texts box , how i save the results in that file
Avatar of tota79

ASKER

i have a texts box , how i save the results in that file
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
O and anougther way might be

Public Function saveFile(lzFile As String, StrData As String)
Dim tFile As Long
   tFile = FreeFile
   Open lzFile For Binary Access Write As #tFile
       Put #tFile, , StrData
   Close #tFile
   
End Function
Public Function OpenFile(lzFile As String) As String
Dim tFile As Long
Dim StrBuff As String, FileToOpen As String

   tFile = FreeFile
   
   Open lzFile For Binary Access Read As #tFile
       StrBuff = Space(LOF(tFile))
       Get #tFile, , StrBuff
   Close #tFile
   OpenFile = StrBuff
   StrBuff = "" 
   
End Function

Private Sub Command1_Click()
   ' to open a file
   Text1 = OpenFile("c:\test.txt")
   ' to save to a file
   saveFile "C:\myfile", "this is some data saved to a file"
   
End Sub

hope it helps