Date: Thu, 17 Feb 2005 21:20:45 -0600 (CST) From: Mark Jacobson To: TSEliot@uni.edu Cc: 810-151-80@uni.edu Subject: Re: Last assignment folder, Feb 22nd, etc. > difficulty with this assignment? Since VB.Net does not appear to > support fixed length strings in structures, we then have to hard code ------------------ There is no need whatsoever to hard code in fixed length strings. None! ------------------ Are you forgetting the format is: semicolon separtion of records, comma separation of fields within each record? Remember also, how handy the .Split() method can be for strings!!! How do you join back together that which has been .Split(). Read the following carefully, and take notes on it if necessary, if you are still stuck. Biction is HIGHLY recommended, and resisting the urge to write code is also highly encouraged. Do not neglect the UNDERSTAND the problem phase, or it is easy to get stuck driving down a road which takes longer to get there than if you had started out the coding journey later, and spent more time preparing for the coding trip in phase one, understand the problem, and phase two, develop an informal algorithm in English and in pseudocode before phase three, translate the developed idea and algorithm into the detailed code.... For example, for a bucket of 4 records, (recall, capacity is 5). numRecords overflow studentsSet field field field ---------- -------- ----------- 4 False "id1,b,c,d;id2,b,c,d;id3,2,3,4;id4,2,3,4" You have http://www.cns.uni.edu/~jacobson/030VB.NET/MakingVBNETfile.gif on the web page link from our class page, in case you do have your handout handy. What would the .Split(semicolon) produce of the above string in the Dim students() As String students = "id1,b,c,d;id2,b,c,d;id3,2,3,4;id4,2,3,4".Split(semicolon) It would create an array of the FOUR different students. students -------- (0) "id1,bb,cccc,d" (1) "id2,b,ccccccc,ddddddd" (2) "id3,22,3333,44444" (3) "id4,810,063,ADA" Can each students array location's String be .Split on a comma into its FOUR or FIVE fields? Yes. Can you look at the appropriate location in that array to see if you have a match on the ID number you are searching for? Yes!!!!!!!!! If you need to C Change the GPA for the student you find ID number of in students(i) for i in {0, 1, 2, 3}, say students(3) needs to be changed, for example. If you .Split(comma) on students(3), i.e. theFields = students(3).Split(comma) and theFields(0) is equal to IDnumberWeAreSearchingFor, can you change theFields(1) to a new value, or can you change theFields(2) to a new value, or can you change theFields(3) to a new value? And then do the following: theStudent = "" for i = 0 to 3 theChangedGPAStudent = theChangedGPAStudent & theFields(i) next i Could we then do the following? Join back together all the records in the bucket, because ONE of the records has been changed.... students(3) = theChangedGPAStudent, or more likely, students(studentToUpdate) = theChangedGPAStudent ? I believe the answer is, YES, we could do the following! Is there any need for fixed length strings, or the measuring of the length of any string? NO! Can we finally, put the BUCKET field of 4 students back together now? numRecords overflow studentsSet field field field ---------- -------- ----------- 4 False "id1,b,c,d;id2,b,c,d;id3,2,3,4;id4,2,3,4" Dim students() As String (RECALL THIS for your convenience) students = "id1,b,c,d;id2,b,c,d;id3,2,3,4;id4,2,3,4".Split(semicolon) students(studentToUpdate) = theChangedGPAStudent ? for i = 0 to numRecords - 1 studentsSet = studentsSet & students(i) next i Can the entire bucket record now be rewritten back to the file from which it is read? Yes, indeed, it can? > in a VERY short amount of time if it was written in Ada. I am getting > the feeling, from seeing a few of you in the lab working on this at the > last minute with me, and from the fact that only one assignment has > been turned in the day before it was originally due, that I am not > alone. This is NOT all that unusual at all, and I am aware some of you had exams this week, such as the Paul Gray OS exam today. But I have heard from and also been a 061 and 062 and 063 instructor, and watched busy, busy labs the day of and day before an assignment is due. I have done the same myself many times in the past as a student! But I have heard through the grapevine that it is not uncommon for students in any class to really get moving on the assignment about this time, say the day before the due date. And it is not like 810:151 has 20 or 30 or 35 students! :-) Between 10 and 20% who have turned it in is the case, Wright? http://www.cns.uni.edu/~jacobson/030VB.NET/MakingVBNETfile.gif The program has been extended, so the pressure is off, and this note should help clarify where strategy changes in algorithm design and string processing techniques might be in order. Good luck, Mark On Thu, 17 Feb 2005 EdgarAllenPoe@uni.edu wrote: > I'm sorry to bring this up at a late date, but am I the only one having > difficulty with this assignment? Since VB.Net does not appear to > support fixed length strings in structures, we then have to hard code > in the fixed legnth strings and such. It seems like I am spending more > time modifying what should be a relativly simple task (loop through an > array of records) and just brute force retyping out the names of the > code. I am writing more code to try and kludge the assignment into > working than i am to meet the specifications. For example I set up my > search routine to read each value in the hard coded string. Since it is > not in an array i have to check each value AND/OR include massivly > complex if statments to control the flow, rather than just exiting a > loop. Additionally I am running into the problem where if i attempt to > see if the search key is equal to the value of a field, I have to > kludge together a method to handle a NULL feild value, as an exception > will be thrown. I am not trying to just complain, but i am wondering > how other people are handling this assignment and solving these > problems. I think my main concern is that this assignment goes WAY > beyond what the book covered or lecture covered. It is not that i am > not comfprtable witht eh concepts, but that 5 weeks and the beginners > book was not enough to enable me with the tools needed to complete this > assignment. For instance, I would most likely be able to complete this > in a VERY short amount of time if it was written in Ada. I am getting > the feeling, from seeing a few of you in the lab working on this at the > last minute with me, and from the fact that only one assignment has > been turned in the day before it was originally due, that I am not > alone. > > Sorry about the long email, but i am pretty frustrated with this > assignment and my difficulties getting it to work. > > John Coltrane > feel free to reply to me on or off this list. > >> >> Please see the web page: >> >> http://www.cns.uni.edu/~jacobson/c151VB.html >> >> See especially, > http://www.cns.uni.edu/~jacobson/emailAddChangeDelete.txt >> >> and >> > http://www.cns.uni.edu/~jacobson/emailLastAssignVBNET.txt >> >> Only one student so far has picked up a manilla envelope from my office >> door, but you can certainly wait till you get here to put the diskette and >> printouts and audit trail material into the envelope, and then slide it >> under my door (if I am not here). That is easier than carrying the folder >> around with you anyway! Your own envelope or folder is fine too. >> >> Try to have your last Visual Basic .NET A, C, and D transactions >> assignment done by Tuesday, February 22nd. You do NOT have to have >> it done by tommorrow. The due date is extended. >> >> Mark