![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Nov 2006
Posts: 19
Rep Power: 0
![]() |
QBasic
I figured QBasic isnt the same of Visual Basic or .net, so, posting here.
I am trying to learn it via online tutorials. Not the best method of approach I realize, however, it is my only means at the time. Anyway, I've gotten to chapter 3 of the tutorial, and am having a bit of trouble with the "homework". It is as follows: Your homework is as follows. Using an array, ask the user for input 5 times (you can use a FOR...NEXT LOOP!) and assign each number they input to an element in the array... then ... create a file and put the five numbers into that file. Make sure to erase the numbers from the last time you ran the program! This is all good and well, but this was never explained in the tutorial. I understand how to use the FOR...NEXT loop, but not whilst using an array. My best attempt, simply gave me a text file with five 0's. CLS DIM Numbers(5) FOR Numbers(5) = 1 TO 5 PRINT "Enter a number." INPUT Numbers NEXT OPEN "Numbers.txt" FOR OUTPUT AS #1 PRINT Numbers(1) PRINT Numbers(2) PRINT Numbers(3) PRINT Numbers(4) PRINT Numbers(5) CLS END Now, this may appear to be glaringing obvious to you guys, but please bear in mind, I have no programming experience whatsoever outside of HTML, and I really wouldn't even consider that programming. Reading over the tutorial, it would appear that this would be the correct way to achieve the correct end result. In fact, I'll go ahead and put the tutorial on here for you guys to look over if you feel the need. Thanks. Last edited by Mjordan2nd; Nov 23rd, 2006 at 11:26 AM. |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 825
Rep Power: 4
![]() |
Its been a while since I did any basic, but just to point you in the right direction:
FOR Numbers(5) = 1 TO 5 PRINT "Enter a number." INPUT Numbers NEXT Line 3 - You want to input into a particular item in Numbers, so use the array access Numbers(n). So something like: FOR n = 1 TO 5 PRINT "Enter a number." INPUT Numbers(n) NEXT Similarly you can use a for loop for the output. |
|
|
|
|
|
#3 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
~Added code tags
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
|
go here for qbasic help http://forum.qbasicnews.com/
im supprised you didnt find that place alread.
__________________
i dont know much about programming but i try to help |
|
|
|
|
|
#5 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
well, it's a far cry from vb or .net in many respects, but the coding is similar on some levels (like this particular one).
any reason you picked QBASIC?
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
#6 | |
|
Professional Programmer
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4
![]() |
Folks, you're doing this guy's homework! It's not like he was even stealthy about it...
Quote:
__________________
"I'm not a genius. Why do I have to suffer?" |
|
|
|
|
|
|
#7 | |
|
Expert Programmer
Join Date: Jun 2005
Posts: 825
Rep Power: 4
![]() |
Quote:
2. He showed that he was trying to do the work. All I did was point out some syntax errors in his code. 3. Four lines of code and some explanation does not constitute "doing this guys homework". Are you trying to say we should just ignore all questions about homework? I thought that was the one of the reasons for this forum, people get stuck on a coding problem after giving it a try, then ask for help. |
|
|
|
|
|
|
#8 | |
|
Newbie
Join Date: Nov 2006
Posts: 19
Rep Power: 0
![]() |
Quote:
Once I get QBasic down, it will be easier to transition to a more advanced language. |
|
|
|
|
|
|
#9 |
|
Newbie
Join Date: Nov 2006
Posts: 19
Rep Power: 0
![]() |
It's not technically homework. It is a good tutorial, and gives you the oppourtunity to learn through doing it yourself. Even if someone gave me the complete code for the "assignment", I would still learn what I was supposed to by seeing it work.
|
|
|
|
|
|
#10 |
|
Professional Programmer
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4
![]() |
The Dark and m0rb1d: OK, my bad, please accept my apologies. I need to read a bit more carefully before I start mouthing off in future.
I started out with a simple old BASIC too - I first programmed on ORIC Micros in a variant of Microsoft BASIC back in the days of mandatory line numbers and no named procedures and went through BBC Basic (named procedures; wow!), RM BASIC and QBASIC before I finally made it into C. While I can't deny programming in BASIC was plenty of fun, I would generally recommend starting with a simple but /good/ language (like Pascal or C); starting in BASIC can make it more difficult to shift to the real world later on. I think all dialects of BASIC are in the process of fading out now (VB.NET is a bit of a last gasp I suspect and I've yet to find anyone who actually uses it - most of the VB6 programmers I know are making the move to C# rather than VB.NET). Still, if you've started you may as well continue; just don't get stuck in BASIC for too long. It teaches bad practices and leads to unhelpful expectations. Good luck and have a lot of fun with it though. And don't let miserable old farts in forums who don't read your questions properly and jump to conclusions bother you ... heh.
__________________
"I'm not a genius. Why do I have to suffer?" |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| QBasic | Antidisestablishmentarian | Other Programming Languages | 13 | Jan 23rd, 2006 5:28 AM |
| Qbasic | zorin | Coder's Corner Lounge | 18 | Sep 24th, 2005 4:05 PM |
| QBasic!!! | OceanSoul | Other Programming Languages | 8 | Jul 7th, 2005 4:02 PM |
| QBasic | Clotters | Other Programming Languages | 3 | May 27th, 2005 8:11 PM |
| Help with a QBASIC program | phoenix987 | Other Programming Languages | 4 | May 5th, 2005 12:27 PM |