Question

I recently got an assignment where I volunteer to teach kids a basic programming language. I chose Small Basic, as it's relatively easy to learn and teaches the basics of programs (if, for and while).

I haven't used it much before (I learned how to do if/for/while loops but that's about it) and was wondering if there's a way to comment out lines of code at a time. For example, in C# you can do this:

//Comment

//Comment

Or

/*Comment

Comment

Comment/*

Is there a way to do the latter in small basic? I know you can do this:

'Comment

'Comment

Etc, but can you do a ton of lines at once?

Était-ce utile?

La solution

Just like in Visual Basic, there is no way to handle multi-line commenting all at once. You have to manually input each apostrophe.

If you want to comment out a correctly-formatted piece of code, one way to "comment" it out would be to place it in an If (False) ... EndIf block, but it's generally not recommended in any language.

Source

Autres conseils

Alternatively, turn the section of code into a dummy subroutine that is never called:

Sub dummy ... EndSub

The advantage of not commenting-out code is that SB will check the syntax and variable declarations for you, so once the code is reinstated it will work straight away. Then again if you put 'random' stuff into that section you may feel this is a dis-advantage! :-)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top