I'm new to programing in Visual Basic, but what im wondering is, how can i open a file and create a file by clicking a button?
Like when i click button 1 it creates a file (to desktop) and when i click another button it opens a specific file(declared in code)
Could anyone help? Thanks in advance
I believe That something along these lines can help you, This allows you to use something like
- Call SetFileContents(App.Path & "\MyFileName.txt", "This Is My Content")
that will create a file called MyFileName.txt, and write This Is My Content to the file. And it all depends on what you want to do with the file that you have created, wether you want to use it as a temp file to store vars to, or just to make a program think that there is somehting there... etc etc.. its a bit like recycling... the possibilities are endless :P lol But i hope this helps you out...
-
Public Sub SetFileContents(ByVal file_name As String, ByVal contents As String)
-
Dim fnum As Integer
-
-
' Open the file.
-
fnum = FreeFile
-
Open file_name For Output As fnum
-
-
' Write the file's contents (without an
-
' extra trailing vbCrLf).
-
Print #fnum, contents;
-
-
' Close the file.
-
Close fnum
-
End Sub
Kind Regards
Devon.