How to create a txt file in VB6
sylvie
-
MISOUI4 -
MISOUI4 -
Hello forum
I need to create a txt file in VB6
Does anyone have an idea?
Thanks in advance
I need to create a txt file in VB6
Does anyone have an idea?
Thanks in advance
12 answers
-
Here is a simple code to place in the code associated with the button
To be adapted according to your needs. The VB help provides all the additional information on the open and print commands.
dim f as integer
f = freefile
open "c:\monfichier.txt" for output as #f
print #f, "small text"
close #f -
dac
but how do you want to create your text file from what? -
This is what I used to save text displayed in a textbox with selected file representing the file path
Dim SelectedFile As String
Dim vari As Integer
Dim contenu As String
Dim chemin As String
Private Sub save_Click()
vari = FreeFile
contenu = Form1.visualisation.Text
' file path to save
chemin = SelectedFile
' opening the file
Open chemin For Output As #vari
' saving the text
Print #vari, contenu
' closing the file
Close vari
End Sub -
Hello
to create a txt file in vb6, simply write the following code:
Open "C:\monfichier.txt" For Input As #1
return = Chr$(13) + Chr$(10)
Line Input #1, text
all = text
If Len(all) <> 0 Then
While Not EOF(1)
Line Input #1, text
all = all + return + text
Wend
End If
Text1.Text = all
Close #1
hoping that I get at least some help -
-
-
You can type your text in a textbox and then create it from a save button, otherwise I will look at the codes to guide you to do it with some code.
Still, check the forums and the internet to see if you can find a source code that would help you.
+++ -
-
-
-
Hi Mophi and Elrin
Both programs work wonderfully.
But when I wanted to copy the content from another text file to paste it into the created file, it gives me errors.
But still, thank you. -
Super mini - tutorial, works wonderfully indeed :-)
But! .. quick question, how can I extract the content of the entire FlexGrid and copy it into a text file?? .. regardless of the text formatting afterwards ..