Jump to content
  • Advertisement
Sign in to follow this  
Froley

Text in VB

This topic is 4064 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've just started using VB and I was wondering how to print text in. Back in old BASIC you just have to type something like this... Print "Hello World" How do you do that in VB?

Share this post


Link to post
Share on other sites
Advertisement
Well, Visual Basic is different from BASIC. A blank project has a form, you can add a label to your form. Name it 'Label1'. Then in your code, you type:

Private Sub Form_Load()
Label1.caption = "Hello World"
End Sub

Press run, and when it loads, the label should say Hello World.

Ben

(Haven't used VB in the last couple of years, going to install V Studio 05 tomorrow, got this info of a tutorial. I'll check the code once I've installed it, and if you need any more help, I can give it then.)

Share this post


Link to post
Share on other sites
Aye, it's not about console output any more. Basically if you have something you want to output, you can indeed output it to a label on a window (as above), or into a textbox, etc...

I had the same problem when I made that conversion from QBasic to VB. It's a very different world in Windows, but start with that code posted above and let us know if you have any questions.

If it helps, another thing to remember is that VB is event-driven. It's not so much about running a program from beginning to end as in QBasic, but rather it's about responding to what the user does to the components you drop into forms.

Text Boxes, Buttons, etc... (everything you can drag and drop onto one of those visual forms) has several "events" that when the user does the related action, you can have code run in immediate response.

For example, a button has a "Click" event. (Try double-clicking on a button that you drag into a VB form to create the Subroutine that will "respond" to the "Click" event) Whatever code you write within that click response subroutine will be run when that button is clicked.

Hopefully this helps. It's a big paradigm change from QBasic (and console-based programming in general), but with time you'll get used to it. Let us know if you run into any more questions!

Share this post


Link to post
Share on other sites
Wow, much better explained than me:P I'm surprised my code was correct, haven't touched VB in years lol. PM me if you need any help...now, off to install V Studio

Share this post


Link to post
Share on other sites
Alternatively, create a new console program and use Console.WriteLine("Hello, World") [smile]

(Either set a breakpoint on the program's final Exit Sub or run without debugging - Ctrl+F5 - to keep the window on-screen from Visual Studio).

Share this post


Link to post
Share on other sites
Aye latest versions of VB has kinda of come full circle in that you can actually write old style console/command line programs again if you want but the syntax is completely different so it's not really VB anymore?

Share this post


Link to post
Share on other sites
Thanks for the help on this subject it's been quit a large jump from BASIC to VB. Your answers did help a lot.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!