Forms in Random access files

Reply

Join Date: Nov 2003
Posts: 11
Reputation: KatB is an unknown quantity at this point 
Solved Threads: 0
KatB KatB is offline Offline
Newbie Poster

Forms in Random access files

 
0
  #1
Nov 17th, 2003
Okay I have a new assignment. I think I actually get the whole random access files ( I hope) but I have no clue as to how to set up my form(s). Does anyone have advice on how to set up the forms?

Here is the assignment.

Objectives: This assignment is intended to provide you with experience using random access files, the common dialog control, Dir function, printing reports, and creating menus.

Problem: Phrank & Schtein were extremely pleased with your work on the 800-WIZARDS ordering system and have threatened to turn me into a toad if I don't require you to develop another application that they need. They are hoping that you will be able to write a program to help them maintain their product inventory file that contains critical information about each of the products that they stock.

Program: Your application should perform the following tasks:

1) Using the common dialog control, allow the user to enter the file paths and names to be used. Make sure you handle the cancel button correctly. You can verify that the file exists using the Dir function.

2) Store the Product Ids and the record numbers from the index file in a list (use the itemdata property to store the record number). Allow the user of the program to select a product ID from the list and then use the associated record number to read the correct record from the random access file

a) The index information is contained in the file P&SPRDCT.NDX which contains up to 30 records, each of which contains the product ID (string * 6) and a record location (integer).

b) The random file P&SNVNTR.RND contains the following fields:

Field
Type
Manufacturer String * 15
Manufacturer phone String * 10
Qty in stock (units) Integer
Lots on order Integer
Qty per Lot Integer
Lot price Currency
Expected Shipment Date String * 10 (MM/DD/YYYY)


c) Provide the user with the ability to change any of the values contained in the inventory file. The update inventory information screen is to be a separate form from the one in which the user enters the product ID.

d) Allow the user to print a copy of the inventory information form.

3) Allow the user to print a copy of the current information stored in the inventory file along with the product ID (use the index and print the records in the order that they are listed in the index). The information should be printed under appropriate column headings and spaced into columns using Tab().

Turn In: TOE chart.
Files P&SPRDCT.NDX and P&SNVNTR.RND (after updates).



Test Data:
Product ID
Changes
PQ3250 Delete the shipping date. *Print*
HU1260 Order 50 lots, expected shipping date 5/17/96.
WB1234 Change Lot Price to 27.00
HB3140 Change Qty per Lot to 20 & Lot Price to 105.00 *Print*
NL8120 Change Qty per Lot to 150 & Lot price to 100.00
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 27
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Forms in Random access files

 
0
  #2
Nov 18th, 2003
Ok, thanks for the run down, but as the guidelines for posting here at Techtalk, is that you show some attempt at your assignment, and we can give guidance when you get stuck.

Now after saying that;

And for staters are you doing this in Visual Basic or Visual Basic.Net??

From what I have read, quickly mind you, it would seem that you do not need multiple forms - therefore not MDI, but SDI. So the one form could have a listbox filled with the product ID's that can allow for selection. And have an open and save button which would load respective CommonDialog Boxes to handle opening and saving files respectively. The same code would be reusable for the menu class for the same Dialog boxes.

Hope this helps. Get back to us if you have any logic or coding type difficulties.

Take care
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Join Date: Nov 2003
Posts: 11
Reputation: KatB is an unknown quantity at this point 
Solved Threads: 0
KatB KatB is offline Offline
Newbie Poster

Re: Forms in Random access files

 
0
  #3
Nov 18th, 2003
first I am taking Visual basic 6.0. My instructor has said that he wants two forms. One with a list box to hold the IDs and an open button and a second with textboxes to make changes to the files.

I have the Ids going into the list with the following code but how do I use the itemdata property to store the record number

Private Sub Form_Load()
Dim strProductID As String
Dim intRecordNumber As Integer
intRecord = FreeFile
Open "A:/P_SPRDCT.NDX" For Input As #intRecord
Do While Not EOF(intRecord)
Input #intRecord, strProductID, intRecordNumber
lstProduct.AddItem strProductID

Loop
Close #intRecord
End Sub
Reply With Quote Quick reply to this message  
Join Date: Nov 2003
Posts: 11
Reputation: KatB is an unknown quantity at this point 
Solved Threads: 0
KatB KatB is offline Offline
Newbie Poster

Re: Forms in Random access files

 
0
  #4
Nov 18th, 2003
I added this is it correct?

Open "A:/P_SPRDCT.NDX" For Input As #intRecord
Do While Not EOF(intRecord)
Input #intRecord, strProductID, intRecordNumber
lstProduct.AddItem strProductID
lstProduct.ItemData(lstProduct.NewIndex) = intRecordNumber
Loop
Close #intRecord
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 27
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Forms in Random access files

 
0
  #5
Nov 18th, 2003
Looks good so far. Good work!
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Join Date: Nov 2003
Posts: 11
Reputation: KatB is an unknown quantity at this point 
Solved Threads: 0
KatB KatB is offline Offline
Newbie Poster

Re: Forms in Random access files

 
0
  #6
Nov 19th, 2003
okay now I have two forms made up. The first has the listbox filled from the code above as well as a dialog control to open a file for random access. The professor said the 2nd form is to have textboxes so when the file is opened it should fill into the textboxes. I am working on that. What I don't understand is how to link the two forms. Like when the open button is pushed the 2nd form is acitvated and filled in. Any ideas?

Kat
Reply With Quote Quick reply to this message  
Join Date: Nov 2003
Posts: 11
Reputation: KatB is an unknown quantity at this point 
Solved Threads: 0
KatB KatB is offline Offline
Newbie Poster

Re: Forms in Random access files

 
0
  #7
Nov 24th, 2003
I have worked all weekend and have come up with the following code but it is not working correctly Instead of filling out the textboxes with each bit of info it puts the same info (the entire file) into each textbox.

Private Sub cmdOpen_Click()
Dim GetFree As Integer, Textline As String, Manufacture As String, ManPhone As String, QtyStock As Integer, LotOrder As Integer, QtyLot As Integer, LotPrice As Currency, Shipping As String
GetFree = FreeFile
CommonDialog1.Filter = "Random Files(*.rnd)|*.rnd|All Files(*.*)|*.*"
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Input As #GetFree
Do While Not EOF(GetFree) 'Loop until it reaches the end of the file

Line Input #GetFree, Textline 'Input 1 line into the variable Textline
frmUpdate.txtManufacture.Text = frmUpdate.txtManufacture.Text & Textline
frmUpdate.txtManPhone.Text = frmUpdate.txtManPhone.Text & ManPhone
frmUpdate.txtQtyStock.Text = frmUpdate.txtQtyStock.Text & Textline
Loop
Close #GetFree
frmUpdate.Show
End Sub
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 27
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Forms in Random access files

 
0
  #8
Nov 27th, 2003
looking good so far KatB!

Hope things are still that way since you post. Sorry, work has been busy so getting back to post on here has been a challenge.

Any other catches?
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Join Date: Jan 2004
Posts: 8
Reputation: c_barnett01 is an unknown quantity at this point 
Solved Threads: 0
c_barnett01 c_barnett01 is offline Offline
Newbie Poster

Re: Forms in Random access files - help

 
0
  #9
Jan 30th, 2004
im having troble with my project. i do not get it please counld someone put random access vb in plan simple english
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 27
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Forms in Random access files

 
0
  #10
Jan 30th, 2004
Random-access file ( or random file) is a file whose data you can read or write in any order without having to read or write all other data in the file.

Ok, what does that mean, well look at it like this (analogy); Say you have guest book at a wedding or tourist site, you have people write their name and where they came from, and any comments they have. Now, anyone visiting can write in the book, at any time and in any order. Hence random right? But to continue with the above definition, every time a guest writes in the guest book, you are not expecting them to read and re-write all the previous entries before them, are you?

No, hence again, Random access. You enter/write data to a file in in any order, but you are not required to read the entire file into memory first, and then add your new data and then write all the data back to the file. Instead you are only going to write the new data to the file, regardless of the data currently in the file.

Hope that made sense?

If it didn't, or you need more than let me know....
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC