944,148 Members | Top Members by Rank

Ad:
Feb 2nd, 2005
0

Sequential Access Data Files

Expand Post »
How do I import a picture from a sequential file. I want the sequential file to have the pathname and filename and that to load the picture as the image.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nicole0904 is offline Offline
13 posts
since Feb 2005
Feb 2nd, 2005
0

Re: Sequential Access Data Files

If I understand you correctly, you want to have a sequential file... that file will have a path in it, to a picture file, that you will load, is this correct?

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. dim seqfile as string
  2. dim tmpvar as string
  3.  
  4. open seqfile for input as #1
  5. line input #1, tmpvar
  6. close #1
  7.  
  8. picture1.picture = tmpvar

Similarly, If You want to have 1 sequential file, with multiple paths (to different pictures), then you could read that into a collection as such:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. dim xPaths as new collection
  2. dim seqfile as string
  3. dim tmpvar as string
  4.  
  5. seqfile = "c:\somefile.dat"
  6.  
  7. open seqfile for input as #1
  8. do until eof(1)
  9. line input #1, tmpvar
  10. xPaths.Add tmpvar
  11. loop
  12. close #1

If I'm way out in left field, then please elaborate your question, and I'll be happy to assist you in any further help that you need.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Feb 3rd, 2005
0

Re: Sequential Access Data Files

I've found a way around that, which I think will be easier for the user. What I'm shooting for is a program where the user enters in the part number and clicks a button and this pulls the manufacturer and product description with a logo. The manager (I'm hoping) will write the information into the sequential file, or update it as necessary(which I'm told is frequently). Right now my code looks like this:

Private Sub cmdGetInfo_Click()

strProdNo = txtProdNo.Text
Do While Not EOF(1)
Input #1, co, part, dscr, ul

If strProdNo = part Then
lblDscrpt.Caption = dscr
lblCo.Caption = co
If ul = "UL1" Then
imgUL.Visible = True
Else
If ul = "UL2" Then
imgUL2.Visible = True
End If
End If
Else
lblDscrpt.Caption = "Not Found"
lblCo = " "
imgUL.Visible = False
imgUL2.Visible = False

End If
Loop

End Sub

With the code like this when I click the button to bring up the info. I get "Not Found"

So I moved the "Loop" to after "Input #1, co, part, dscr, ul"
This will find the last set of data in the Sequential file, but the first record brings up "Not Found"

I'm still playing around with thing, but any suggestions would be nice!
Thanks!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nicole0904 is offline Offline
13 posts
since Feb 2005
Feb 3rd, 2005
0

Re: Sequential Access Data Files

The INPUT has to be within the loop, in order to loop through the entire file. Also, if you have records AFTER the record that is actually found, that are not containing the part number in strProdNo, Then lblDscrpt and lblCo get set to Not found and nothing. So, Pretend that you have a file with:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. not what you want
  2. not what you want
  3. what you want
  4. not what you want

Then The Captions Get Reset on the last line of the file, because it's not what you are looking for. You need to do 1 of two things here.... the best way is to beak out of the loop, before it finishes reading the file. So, Your code would look a little something like this:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub cmdGetInfo_Click()
  2.  
  3. strProdNo = txtProdNo.Text
  4. Do While Not EOF(1)
  5. Input #1, co, part, dscr, ul
  6.  
  7. If strProdNo = part Then
  8. lblDscrpt.Caption = dscr
  9. lblCo.Caption = co
  10. If ul = "UL1" Then
  11. imgUL.Visible = True
  12. exit do
  13. Else
  14. If ul = "UL2" Then
  15. imgUL2.Visible = True
  16. exit do
  17. End If
  18. End If
  19. Else
  20. lblDscrpt.Caption = "Not Found"
  21. lblCo = " "
  22. imgUL.Visible = False
  23. imgUL2.Visible = False
  24. End If
  25. Loop
  26. End Sub

I'm not sure if that will help or not.... drop a line and let me know. k?
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Feb 3rd, 2005
0

Re: Sequential Access Data Files

That is perfect!
Thanks a bunch!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nicole0904 is offline Offline
13 posts
since Feb 2005
Feb 3rd, 2005
0

Re: Sequential Access Data Files

You're very welcome
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Feb 7th, 2005
0

Re: Sequential Access Data Files

Ok now I want the user to use a separate program to enter in the information that is read. I've entered in two sets of data to test. I can enter them in fine. They look all right in notepad, but when I run the program that is reading from the file. I get the input past end of file error or it will only read the last set of data entered. I know why I'm getting input past end of file error, there is an extra space after the last entry. I delete that and then it won't find the first entry.

If this isn't clear or you want my code email me
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nicole0904 is offline Offline
13 posts
since Feb 2005
Feb 7th, 2005
0

Re: Sequential Access Data Files

I'm sending you an e-mail right now
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: vb and excel password and username
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Listbox with Columns





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC