2 Replies - 1457 Views - Last Post: 10 May 2010 - 01:11 PM Rate Topic: -----

#1 tbroom93   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-May 10

Loading data from a .txt file

Posted 10 May 2010 - 12:50 PM

Hi, I am making a small program in VB6 which will save (Customers) details from numerous text Boxes into a .txtFile, for each new customer There will be a new file unique to them via there "UserID"(Each new file Will be called whatever is inside the UserID txtBox). I have managed to get the program saving the details along with naming the file via the UserID.
 
Private Sub cmdSave_Click()
 Dim UserID As String 
  UserID = txtUserID & ".txt"
   Open UserID For Output As #1
        Print #1, txtUserID
        Print #1, txtName
        Print #1, txtSurname
        Print #1, txtAddress1
        etc.....  


Im having trouble trying to load the data from the txtFile (VIA the UserID) back into the textboxes
I have tried doing this...
Dim UserID As String 
UserID = txtUserID & ".txt"
  Open UserID For Input As #1[attachment=18156:vb6.zip]
        Input #1, txtUserID
        Input #1, txtName
        Input #1, txtSurname
        Input #1, txtAddress1 etc.....


and it is not working, it keeps saying "Variable required - can't assign to this expression"

Any help would be much appreciated.

Attached File(s)

  • Attached File  vb6.zip (53.77K)
    Number of downloads: 163


Is This A Good Question/Topic? 0
  • +

Replies To: Loading data from a .txt file

#2 Rhymer   User is offline

  • D.I.C Regular

Reputation: 23
  • View blog
  • Posts: 282
  • Joined: 21-April 09

Re: Loading data from a .txt file

Posted 10 May 2010 - 01:10 PM

I am pretty sure that you cannot load directly into a control from an input# or a line input#. You will need to use an appropriate variable to assign the incoming data to first and then put it into your control. Something like...

Dim IntVar as integer
input #1, intvar
txtbox1=intvar (will convert it to a string automatically for the text box)

or... just use string variables unless you will want to do any math on the data.

Rhymer

Edit: Also you may need to put double quotes around any data that may have a comma such as an address or it will screw up the data on input.

This post has been edited by Rhymer: 10 May 2010 - 01:11 PM

Was This Post Helpful? 0
  • +
  • -

#3 raziel_   User is offline

  • Like a lollipop
  • member icon

Reputation: 469
  • View blog
  • Posts: 4,280
  • Joined: 25-March 09

Re: Loading data from a .txt file

Posted 10 May 2010 - 01:11 PM

check this out
http://www.dreaminco.../snippet318.htm
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1