If you don't mind me asking, why does it have to be done in a random file? Homework? If there is any other way, believe me, you want it. That said, I've added a button (Debit Button) To Your Project, that debits a given amount from the selected account. Hope your up for a bit of constructive criticism, because I'm about to lay it out. One Thing, is I would change the setup a bit, so that you don't have to select a file, and then seperately display the records in it with another button. Both Of those operations should go hand in hand, for user interface comfortability.... You select the file, and Bam, Everything is Ready. Speaking of which, have you clicked the button to load a file, and then clicked "Cancel" on the common dialog box? Nice Surprize there.
You made life a bit more complicated by using a sorted listbox.... my first plan was to add a new listbox that would remain hidden, and would directly coorespond to the record selected in the listbox, but you can't keep record numbers in line with record info, when the listboxes get sorted.... SO, we had to rip apart the information (by " ") in the listbox, and then open the file and loop through every record, and compare it to the card number and the pin. If both of those matched, then we set a variable that contains the record number that was selected by the user in the listbox. Then we load Acct (The user defined type) with the information of the record that was selected by the user. We pop up an inputbox asking for the amount to debit, and we check if the amount to debit would make the account balance negative. if so, we pop up a msgbox asking if it's OK for them to go into the negative balance, if not, we leave the sub, if so (or if the balance would not be negative after the transaction), we deduct the amount from .currentbalance, and re-write the information to the file, at the position of the selected record. Then we programmatically "click" your button that loads the data into the listbox (so that it updates after the debit) and that about does it.
Another thing, is that I commented out your option explicit (I hate rules... I always have). If you want to add it back in, be my guest, but I did not define 3 of my variables, 1 array of type string, and 2 scalar of type string (Rparts [array for record parts], CardNo [To Get The Card Number of the selected record from the listbox], and PinNo [Also Taken From the Info in the listbox])
This should give you a pretty good idea of what you have to work with, and the code is commented pretty well, so you should be able to get a feel of what you need to do to credit the account, or do whatever else is needed. If you don't mind my critique, and you need any more help, just let me know.
Last edited by Comatose; May 14th, 2006 at 4:22 pm. Reason: Forgot Attachment