how to save text box data to a new file,not in same file - TechRepublic
Question
July 21, 2007 at 01:28 PM
dilip_bagdi2005

how to save text box data to a new file,not in same file

by dilip_bagdi2005 . Updated 18 years, 10 months ago

i am trying to save my text boxes data to a new file through command button,but text boxes data is saved in the same file it saved last this is my code

Public Sub SaveTextBoxData(ByVal formSource As Form, ByVal fileName As String)
‘This will save all data currently in ant text boxes on the specified form

Dim counter As Control ‘used to cycle through the controls on a form
Dim fileNum As Integer ‘holds a handle to the file

‘open the file for writing
fileNum = FreeFile
Open fileName For Output As #fileNum

‘cycle through the controls on the form
For Each counter In formSource.Controls

‘is this control a text box
If TypeOf counter Is TextBox Then

‘save its Text property
Print #fileNum, counter.Name + “=” + counter.Text
End If
Next counter
Close #fileNum
End Sub

Private Sub savemnu_Click()
CommonDialog1.ShowSave
Call SaveTextBoxData(Me, App.Path + “.txt”)
End Sub

so please help me so that each time when i click save a common dialog box should appear and i can save the forms content to a new file..

This discussion is locked

All Comments