Opening and Reading the File.
Author |
Message |
StarGateSG-1
|
Posted: Wed May 24, 2006 9:17 am Post subject: Opening and Reading the File. |
|
|
Hello,
I am having this trouble counting a certain field in a record.
The output comes out like this:
code: | Total Students: 5
Total Students by Grade:
Grade 9: 0
Grade 10: 0
Grade 11: 0
Grade 12: 0 |
And it should come out like this:
code: | Total Students: 5
Total Students by Grade:
Grade 9: 1
Grade 10: 1
Grade 11: 1
Grade 12: 1 |
I can't really give any more information, becasue this is all I know.
I have added a demo version with fake data because it is personal data, but the program is layed out the same.
Thank you.
Description: |
|
Download |
Filename: |
Attendance program.zip |
Filesize: |
6 KB |
Downloaded: |
121 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Brightguy
|
Posted: Wed May 24, 2006 3:29 pm Post subject: Re: Opening and Reading the File. |
|
|
No offence, but that's some brutal code.
I'd suggest getting a book on VB and working through it from the very beginning; you should know the basics before starting with file input.
If you need clarification about something, we should be able to help you out.
|
|
|
|
|
|
StarGateSG-1
|
Posted: Wed May 24, 2006 5:36 pm Post subject: (No subject) |
|
|
I don't have time to take the 6 weeks to learn all the in's and outs of VB, So your help is need and will be greatly appreicated if you can help with what it is now.
The code is that bad ethier, I do have a book and most of that code is drawn rigth form the book. It is a great book to. takes you step by step form basics to dynamic web pages and databases.
|
|
|
|
|
|
Brightguy
|
Posted: Wed May 24, 2006 8:06 pm Post subject: Re: Opening and Reading the File. |
|
|
Well, there are a few things I immediately noticed that would probably be described in the very beginning of any good VB book:- Indentation of code
- Use of Option Explicit
- Proper variable declaration
- Some whitespace wouldn't hurt either, and underscore line-continuation
Actually, once you indent the code properly, I bet you'll quickly see why you are getting 0 for each grade total. Seriously, I can't imagine doing any kind of application without indentation. It's that essential.
As well, there's a second problem why you're getting 0s, your Mid() starting point is off. BTW, in the cases you posted you can just use Right().
|
|
|
|
|
|
StarGateSG-1
|
Posted: Wed May 24, 2006 8:49 pm Post subject: (No subject) |
|
|
I have tryed many values of mid and I have tryed right, (did you try and use them??) and none of them work, and the book is a quick leanr book that focuses more on examples, and getting the job done. I am not planning to continue with Vb in the future. This is a project leanr Vb well enough to write a function program that cna be edited and used for many years.
Also My program is very far from being done, sadly Vb doesn;t auto indent which mean in a final copy I will probably indetn but not not, I need to get it working first. There is a certain order you must follow when writing programs on a strict timeline. Get the job done first and then make it pretty. You can complain about the mssy code but there is a reason, mainly I can read it for now.
Indent won't make the problem better to see, I can do that with my brain.
|
|
|
|
|
|
Brightguy
|
Posted: Wed May 24, 2006 11:36 pm Post subject: Re: Opening and Reading the File. |
|
|
I think you're approaching the problem like you only want to learn when something goes wrong, so that you can fix it and move on. However, I think that spending some time on the basics now will allow you to ultimately write the program quicker, easier, and with less bugs. Your deadline is unfortunate, but ask yourself: can you do high-quality work while you're just beginning to learn the language?
Here's what I suggest about Mid(): study the definition of the function, and figure out the correct values to pass based on that. Continually trying different numbers until you get something that works does not help you understand what's happening.
|
|
|
|
|
|
StarGateSG-1
|
Posted: Thu May 25, 2006 8:40 am Post subject: (No subject) |
|
|
I know how mid works. That is not the problem, at best guess I think it has to do with the EOF becasue it reads to the end once and I use the same variable again to read the seocnd time, that could be it.
I Wish I had more time to do this properly, but I can not afford another week to go into the basics and problem solve my way through.
|
|
|
|
|
|
StarGateSG-1
|
Posted: Thu May 25, 2006 12:48 pm Post subject: (No subject) |
|
|
I need to apologize, that error was purely stupid mistake because I was rushin and it was a logic error.
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
|
|