Create a file in visual basic 6

Solved
abdess111 Posted messages 41 Registration date   Status Member -  
 blink23 -
Hello everyone
I am a beginner in VB and I made a little program that helps you enter the prices of purchases and the program directly stores these prices (after adding tax) in a list box. My problem is that I want to save this list on my hard drive in a text file, and then print it. So I don't know how I can create a text file on my hard drive that contains this list (purchase prices). And how can I print a file that is on the hard drive from the program that is in VB6
I hope you can help me because I need to finish this program thank you thank you thank you
Configuration: Windows XP Firefox 2.0.0.12

6 answers

Polux31 Posted messages 7219 Status Member 1 204
 
Hello,

Here is the method to create a .txt file:
Public Sub SaveFile() Dim fp As Integer Dim path As String Dim i As Long fp = FreeFile path = "c:\BackupMyFile.txt" On Error Resume Next Open path For Append As #fp For i = 0 To ListBox1.ListCount - 1 Print #fp, ListBox1.List(i) Next i Close #fp If Err <> 0 Then MsgBox Err.Description Exit Sub End If End Sub


;o)

polux
4
abdess111 Posted messages 41 Registration date   Status Member 1
 
Thank you very much for helping me
and if I want to print this file??
thank you in advance :-)
0
Polux31 Posted messages 7219 Status Member 1 204
 
re,

I think you can use a CommonDialog (Ctrl+T -> Microsoft CommonDialog ...) and set up the properties for printing.

Keep it up

;o)

Polux
0
abdess111 Posted messages 41 Registration date   Status Member 1
 
Alright, thank you very much.
0
kaoto
 
Bonsoir à tous, je suis étudiant en deuxième année de génie logiciel. Mon professeur de VB nous a donné comme projet de créer un logiciel de gestion d'une entreprise de vente, location et dépannage d'automobiles, nommé JUBY AUTO. Le souci, c'est qu'il faut le faire avec des fichiers pour les enregistrer, mais nous n'avons pas encore travaillé sur les fichiers ou je n'ai pas bien saisi l'introduction. S'il vous plaît, aidez-moi avec quelques conseils pour le graphisme, cela serait le bienvenu. Merci.
0
blink23
 
I need help from you who seem knowledgeable
I am a student and I have to complete a project calculating income tax and I am trying to do it myself
I am working with a form containing
income and joint income entered by the user
then I would like VB6 to calculate for me
a total income with a simple sum
a deduction of 10% of this income
a gross taxable income being the total income - the deduction
a tax calculation
All this may seem simple to you but it is difficult when you are a beginner
Actually, the goal is for the user to enter their income and for everything to be calculated by a command button and finally for the result to appear in Excel
I understand that the whole program is long, I just want some help. Thank you in advance
0