Your assignment is to write a program for a computer dating service. Each client
ID: 3527005 • Letter: Y
Question
Your assignment is to write a program for a computer dating service. Each client gives you his or her name, phone number, and a list of interests. It is your job to maintain lists of men and women using the service and to match up the compatible couples. You will find more details about the assignment, including the inputs, outputs, and deliverables in the course environment. Input Data about current clients should be on file "Clients.mf". For each current client, the file contains the following information: Sex 1 character, 'M' or 'F' Name up to 20 characters, followed by comma Phone Number 8 characters Number of Interests an integer List of Interests 10 characters each separated by commas with a period after the final interest. Match up to 20 characters, followed by end-of-line. From the keyboard: The user may enter on of the following commands. Command Processing NEWCLIENT Add the client to the appropriate list by storing the appropriate information. Attempt to match this new client with a member of the opposite sex. A match occurs when the clients have three or more of the same interests. (You only have to find the first match for each new client.) Make sure you then designate both persons as matched, as described in the section on data structures above. Print the name of the new client, the name of his or her match, and both phone numbers. If no match is found, print an appropriate message. UNMATCH Unmatch this name with his or her current match by removing from the matched person. PRINTMATCH Print a list of all matched pairs. PRINTFREE Print the names and phone numbers of clients who are not currently matched. QUIT Stop processing Output Echo print all screen input and output on file "Dates.out." Data Structures The problem requires you to maintain two lists of clients, one for men and one for women. When a new client is added to the list, he or she is added to the end of the appropriate list. Each list element must include all the information for one client: name, phone number, number of interests (maximum number is 10), interests, and the name of this client's current match (empty string if not matched). You must use one of the list classes developed in Chapter 3. DeliverablesExplanation / Answer
PLEASE RATE ME AND AWARD ME KARMA POINTS IF IT IS HELPFUL FOR YOU Option Explicit Sub GetFileList() Dim strFolder As String Dim varFileList As Variant Dim FSO As Object, myFile As Object Dim myResults As Variant Dim l As Long ' Get the directory from the user With Application.FileDialog(msoFileDialogFolderPicker) .Show If .SelectedItems.Count = 0 Then Exit Sub 'user cancelled strFolder = .SelectedItems(1) End With ' Get a list of all the files in this directory. ' Note that this isn't recursive... although it could be... varFileList = fcnGetFileList(strFolder) If Not IsArray(varFileList) Then MsgBox "No files found.", vbInformation Exit Sub End If ' Now let's get all the details for these files ' and place them into an array so it's quick to dump to XL. ReDim myResults(0 To UBound(varFileList) + 1, 0 To 5) ' place make some headers in the array myResults(0, 0) = "Filename" myResults(0, 1) = "Size" myResults(0, 2) = "Created" myResults(0, 3) = "Modified" myResults(0, 4) = "Accessed" myResults(0, 5) = "Full path" Set FSO = CreateObject("Scripting.FileSystemObject") ' Loop through our files For l = 0 To UBound(varFileList) Set myFile = FSO.GetFile(CStr(varFileList(l))) myResults(l + 1, 0) = CStr(varFileList(l)) myResults(l + 1, 1) = myFile.Size myResults(l + 1, 2) = myFile.DateCreated myResults(l + 1, 3) = myFile.DateLastModified myResults(l + 1, 4) = myFile.DateLastAccessed myResults(l + 1, 5) = myFile.path Next l ' Dump these to a worksheet fcnDumpToWorksheet myResults 'tidy up Set myFile = Nothing Set FSO = Nothing End Sub Private Function fcnGetFileList(ByVal strPath As String, Optional strFilter As String) As Variant ' Returns a one dimensional array with filenames ' Otherwise returns False Dim f As String Dim i As Integer Dim FileList() As String If strFilter = "" Then strFilter = "*.*" Select Case Right$(strPath, 1) Case "", "/" strPath = Left$(strPath, Len(strPath) - 1) End Select ReDim Preserve FileList(0) f = Dir$(strPath & "" & strFilter) Do While Len(f) > 0 ReDim Preserve FileList(i) As String FileList(i) = f i = i + 1 f = Dir$() Loop If FileList(0) Empty Then fcnGetFileList = FileList Else fcnGetFileList = False End If End Function Private Sub fcnDumpToWorksheet(varData As Variant, Optional mySh As Worksheet) Dim iSheetsInNew As Integer Dim sh As Worksheet, wb As Workbook Dim myColumnHeaders() As String Dim l As Long, NoOfRows As Long If mySh Is Nothing Then 'make a workbook if we didn't get a worksheet iSheetsInNew = Application.SheetsInNewWorkbook Application.SheetsInNewWorkbook = 1 Set wb = Application.Workbooks.Add Application.SheetsInNewWorkbook = iSheetsInNew Set sh = wb.Sheets(1) Else Set mySh = sh End If With sh Range(.Cells(1, 1), .Cells(UBound(varData, 1) + 1, UBound(varData, 2) + 1)) = varData .UsedRange.Columns.AutoFit End With Set sh = Nothing Set wb = Nothing End Sub posted by NailsTheCat at 2:05 PM on January 13, 2007 [1 favorite] NailsTheCat: Thanks very much - that looks like what I need. I don't have the dsofile.dll though. I've done alt-F11 in Excel, but it doesn't seem to do anything. I'm fairly computer literate, but scripting isn't something that I have any experience with... can you break down the instructions a little more? Thanks again! posted by gwenzel at 5:37 PM on January 13, 2007 The above code just gave you the basic file info. It didn't give you the Title etc. I've added the code to do that. You can download an Excel workbook from here to see it in action. Just click the big grey button. It will work without dsofile.dll but it won't give you the extra fields you want - no way around that as far as I can tell. So you can just d/l that too (from MS). (Just doubleclick to install. You can leave as is in its default directory or move the dsofile.dll to c:windowssystem32 and delete the other example files it installs.) Once you have dsofile.dll on your 'puter you should get a list of all your files in the selected directory plus those Title, Comments, Subject fields too. I don't know why ALT+F11 doesn't work for you :( but you can also access the VBE from Tools Macros Visual Basic Editor. That's where you would have inserted the above code. (Not that you need to now you can d/l the workbook.) Note, the workbook (obviously) contains macros. So you may need to change your security options (Tools Macros Security) to Medium and then open the file, clicking on enable if you get the security prompt. (You can always open disabled first, open the VBE and examine the code to check there's nothing nefarious in there - can't be too careful!) HTH - post back if it doesn't (or email in profile). It's actually quite neat - I may use this myself!! posted by NailsTheCat at 11:15 PM on January 13, 2007 OK - and of course you can also use DSO to write back to the file too. So you can update your Title fields etc. in Excel and then save that back to the file. Just tested it (code is in the file). I'd have to make it a little more user friendly for ya. If you want to test that for now, just select a row (or cell) on the spreadsheet row of the file you want to update, press ALT+F8 and select 'UpdateFileInfo' and click Run. I'm definitely going to use this now!! posted by NailsTheCat at 11:37 PM on January 13, 2007 NailsTheCat: That looks awesome, but I'm getting a glitch - I've figured out the alt-F11 problem (just a keyboard setting that had F-keys disabled) and entered the code into Excel. I've downloaded your sample worksheet, and opened it in Excel; problem is, the grey button gives an error - "Compile error: variable not defined". Any ideas? I'm using Excel 2000, if that makes a difference. I haven't got to the point of having this work yet, but it sounds exactly like what I'm looking for. Thanks so much for your efforts thus far! If you want to move this to e-mail, my address is also in my profile. posted by gwenzel at 3:40 AM on January 14, 2007 It turns out XL2000 does make a difference - it doesn't support the 'browse for folder' dialogue I had used. I've modified it to use a generic windows browse now. I'll send via email. posted by NailsTheCat at 9:07 AM on January 14, 2007 « Older I am looking to buy a house in... | FirefoxMp3Filter: Why are clic... NewerRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.