Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Opening and Reading the File.
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
StarGateSG-1




PostPosted: 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.



Attendance program.zip
 Description:
Here is the file.

Download
 Filename:  Attendance program.zip
 Filesize:  6 KB
 Downloaded:  121 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Brightguy




PostPosted: 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




PostPosted: 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




PostPosted: 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. Very Happy 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




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: 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
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: