Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 05-24-2012, 02:53 AM   #1
In Runtime
 
Join Date: Apr 2012
Location: Canada
Posts: 322
Default Visual basic print error

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

Edsterr is offline   Reply With Quote
Old 05-24-2012, 03:58 AM   #2
Daemon Poster
 
dale's Avatar
 
Join Date: Mar 2012
Location: Taiwan
Posts: 1,008
Default Re: Visual basic print error

Try:
Code:
Form1.Print "Hello"
__________________

__________________
distrACT -- an open community
● It helps to ask questions effectively
● Please join Server admins social group if you are into servers
dale is offline   Reply With Quote
Old 05-24-2012, 06:00 AM   #3
In Runtime
 
Join Date: Apr 2012
Location: Canada
Posts: 322
Default Re: Visual basic print error

No, it automatically puts brackets in, and it still generates an error
Edsterr is offline   Reply With Quote
Old 05-24-2012, 06:36 AM   #4
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 8,003
Default Re: Visual basic print error

what is the error that you are getting?
__________________
I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Old 05-24-2012, 12:12 PM   #5
In Runtime
 
Join Date: Apr 2012
Location: Canada
Posts: 322
Default Re: Visual basic print error

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.
Edsterr is offline   Reply With Quote
Old 05-24-2012, 04:07 PM   #6
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: Visual basic print error

Quote:
Originally Posted by Edsterr View Post
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.
__________________
Save the whales, feed the hungry, free the mallocs.
berry120 is offline   Reply With Quote
Old 05-25-2012, 10:23 AM   #7
In Runtime
 
Join Date: Apr 2012
Location: Canada
Posts: 322
Default Re: Visual basic print error

Quote:
Originally Posted by berry120 View Post
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
Edsterr is offline   Reply With Quote
Old 05-25-2012, 07:39 PM   #8
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: Visual basic print error

Quote:
Originally Posted by Edsterr View Post
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
__________________
Save the whales, feed the hungry, free the mallocs.
berry120 is offline   Reply With Quote
Old 05-28-2012, 09:18 AM   #9
In Runtime
 
Join Date: Apr 2012
Location: Canada
Posts: 322
Default Re: Visual basic print 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.
Edsterr is offline   Reply With Quote
Old 05-28-2012, 09:26 AM   #10
Site Team
 
berry120's Avatar
 
Join Date: Jul 2009
Location: England, UK
Posts: 3,425
Default Re: Visual basic print error

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

__________________
Save the whales, feed the hungry, free the mallocs.
berry120 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 03:38 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0