Visual basic print error

Edsterr

In Runtime
Messages
322
Location
Canada
In school we use Visual Basic 2005 Express Edition for programming. As I'm only doing Int 2 (standard grade), the programs are still quite basic. However the following code generates an error:

Dim Counter as Integer

For Counter = 1 to 10
Form1.Print("Hello")
Next

As you can see, this is just a simple task to demonstrate fixed loops. Unfortunately 'Form1.Print("Hello")' causes a problem, and I've no idea why. I've tried 'Me.Print(...)' and 'Print(...)' and 'PrintLine(...)' and so on, but nothing has worked. Nor can I find any solution in the inbuilt help/search area.

It's probably something obvious and I'm being stupid, but on the off-chance that it's not, any help will be much appreciated eitherway.
 
I'm not sure what it says exactly, but from what I can recall, it (Form1.Print("Hello")) is underlined with a blue line, and it also says something when hovering over it, but I can't remember what.
 
I'm not sure what it says exactly, but from what I can recall, it (Form1.Print("Hello")) is underlined with a blue line, and it also says something when hovering over it, but I can't remember what.

Pasting your exact code and corresponding error (in its exact wording) is the first rule of asking programming questions!

In this case, from my (ancient) knowledge of VB, I would imagine there isn't a print method on the form object - if you want to print text to it, you'll have to paint the text you want on their explicitly. From the example you've given, I'd imagine that's a bit too advanced at present.

Did you mean to just write to the console? If so Console.write() might be what you're after instead.
 
Pasting your exact code and corresponding error (in its exact wording) is the first rule of asking programming questions!

In this case, from my (ancient) knowledge of VB, I would imagine there isn't a print method on the form object - if you want to print text to it, you'll have to paint the text you want on their explicitly. From the example you've given, I'd imagine that's a bit too advanced at present.

Did you mean to just write to the console? If so Console.write() might be what you're after instead.

Sorry I couldn't paste the error, but at school this website is blocked for some reason. I will (if necessary) post the error on Monday.

I'm pretty sure I've already tried Console.write() but I'll give it another shot on Monday
 
Sorry I couldn't paste the error, but at school this website is blocked for some reason. I will (if necessary) post the error on Monday.

I'm pretty sure I've already tried Console.write() but I'll give it another shot on Monday

My VB knowledge is very rusty / obsolete, but I think that should work. As already said though, yup it's generally very necessary to post the exact code and error :)
 
I've just tried 'console.write' and no there appeared to be no error, however when it came to running the program nothing happened.

Here is the error which was displayed when I tried the other code: 'print' is not a member of '_4._7___Repitition.Form1', and as I said it was underlined with a blue line.
 
Console.write won't print it out on the form, it'll print it out on the console.

The error appears to be as I said, there's no print method on the form, so it won't work.

Perhaps you meant to add a label or text box on the form and set the text of that?

You'd do well to find a tutorial or two to follow until you've got a basic grip on things - that would help you progress to a basic level where you can start building more complicated applications.
 
Back
Top Bottom