Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Other Programming Languages (http://www.programmingforums.org/forum38.html)
-   -   QBasic (http://www.programmingforums.org/showthread.php?t=11976)

m0rb1d Nov 23rd, 2006 8:02 AM

QBasic
 
3 Attachment(s)
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.

The Dark Nov 23rd, 2006 8:22 AM

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.

Mjordan2nd Nov 23rd, 2006 12:27 PM

~Added code tags

mrynit Nov 23rd, 2006 10:44 PM

go here for qbasic help http://forum.qbasicnews.com/
im supprised you didnt find that place alread.

bl00dninja Nov 25th, 2006 2:50 AM

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?

mackenga Nov 27th, 2006 3:24 PM

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

The Dark Nov 27th, 2006 3:44 PM

Quote:

Originally Posted by mackenga (Post 119821)
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.

m0rb1d Nov 30th, 2006 8:43 AM

Quote:

Originally Posted by bl00dninja (Post 119682)
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 Nov 30th, 2006 8:44 AM

Quote:

Originally Posted by mackenga (Post 119821)
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.

mackenga Nov 30th, 2006 8:13 PM

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.


All times are GMT -5. The time now is 1:18 AM.

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