Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 23rd, 2006, 7:02 AM   #1
m0rb1d
Newbie
 
Join Date: Nov 2006
Posts: 19
Rep Power: 0 m0rb1d is on a distinguished road
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.
Attached Files
File Type: txt Tutorial 1.txt (10.3 KB, 20 views)
File Type: txt Tutorial 2.txt (8.2 KB, 18 views)
File Type: txt Tutorial 3.txt (4.7 KB, 18 views)

Last edited by Mjordan2nd; Nov 23rd, 2006 at 11:26 AM.
m0rb1d is offline   Reply With Quote
Old Nov 23rd, 2006, 7:22 AM   #2
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 850
Rep Power: 4 The Dark is on a distinguished road
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
Line1 - Don't use Numbers(5) in the for loop, the for loop variable is the "counter" of the for loop. In this case it will go from 1 to 5.
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.
The Dark is offline   Reply With Quote
Old Nov 23rd, 2006, 11:27 AM   #3
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
~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
Mjordan2nd is offline   Reply With Quote
Old Nov 23rd, 2006, 9:44 PM   #4
mrynit
Hobbyist Programmer
 
mrynit's Avatar
 
Join Date: Mar 2006
Location: WA, USA
Posts: 332
Rep Power: 3 mrynit is on a distinguished road
Send a message via AIM to mrynit Send a message via MSN to mrynit Send a message via Yahoo to mrynit Send a message via Skype™ to mrynit
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
mrynit is offline   Reply With Quote
Old Nov 25th, 2006, 1:50 AM   #5
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
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.
bl00dninja is offline   Reply With Quote
Old Nov 27th, 2006, 2:24 PM   #6
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4 mackenga is on a distinguished road
Folks, you're doing this guy's homework! It's not like he was even stealthy about it...

Quote:
Your homework is as follows
Heh. That explains the reason for choosing QBASIC in this day and age I suppose...
__________________
"I'm not a genius. Why do I have to suffer?"
mackenga is offline   Reply With Quote
Old Nov 27th, 2006, 2:44 PM   #7
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 850
Rep Power: 4 The Dark is on a distinguished road
Quote:
Originally Posted by mackenga View Post
Folks, you're doing this guy's homework! It's not like he was even stealthy about it...



Heh. That explains the reason for choosing QBASIC in this day and age I suppose...
1. He clearly states he is doing this from online tutorials. That doesn't sound like homework to me.
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.
The Dark is offline   Reply With Quote
Old Nov 30th, 2006, 7:43 AM   #8
m0rb1d
Newbie
 
Join Date: Nov 2006
Posts: 19
Rep Power: 0 m0rb1d is on a distinguished road
Quote:
Originally Posted by bl00dninja View Post
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 picked QBasic, as I was looking for a starting point that would be easiest for me to pick up on. I've made many attempts at learning programming, but always end up confused, and unable to find an answer. Rationally, I assumed, easier languange, easier to find help.

Once I get QBasic down, it will be easier to transition to a more advanced language.
m0rb1d is offline   Reply With Quote
Old Nov 30th, 2006, 7:44 AM   #9
m0rb1d
Newbie
 
Join Date: Nov 2006
Posts: 19
Rep Power: 0 m0rb1d is on a distinguished road
Quote:
Originally Posted by mackenga View Post
Folks, you're doing this guy's homework! It's not like he was even stealthy about it...



Heh. That explains the reason for choosing QBASIC in this day and age I suppose...
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.
m0rb1d is offline   Reply With Quote
Old Nov 30th, 2006, 7:13 PM   #10
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4 mackenga is on a distinguished road
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?"
mackenga is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:17 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC