Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, February 16, 2015 2:57 PM
I am a complete newbie to 2008, so forgive me. How do I print text on a form in Visual Basic 2008. Also, I am having trouble finding usable documentation on VB 2008, can anyone recommend some good documentation or tutorials?
Best regards,
Randy Boulter
All replies (4)
Monday, February 16, 2015 3:11 PM ✅Answered | 1 vote
Hi
One way is to add a text container type of control to your form and then add the text to it. Typical containers used to display text might be a RichtextBox which can be used to display text that you might want to format with fonts/colours/graphics etc. Another container for plain text is a Textbox control which can be single line for short user input type of use, or multiline for longer/larger blocks of text.
These controls can be added to your Form via the Designer toolbox. They can easily be positioned and their properties set via the Properties dialog.
Regards Les, Livingston, Scotland
Monday, February 16, 2015 3:11 PM ✅Answered | 1 vote
The usual way to show text on a form is to add a Label to the form and set the Label's Text property to whatever text you want to show. If you want the user to be able to update the text, use a TextBox instead of a Label.
For example, if you add a label called Label1 to your form in the form designer, you can set the text displayed in the label either in the designer, or in your code.
Label1.Text = "This the the text I want to display on the form"
If you are new to Visual Basic, I don't know why you would want to use an out of data version (there have been three new versions since 2008, and a fourth is currently being previewed). You can download the free Community Edition of Visual Studio 2013.
Documentation is in the MSDN Library. If you search for a class (such as the Label class), you will find details of all its properties and methods, and usually an example of how to use it. Documentation is still available for older version, for example. the page for the Label class that I linked to is for .Net Framework version 4.5 (which was released with VS 2013). but you can click on the other versions link to go to the documentation for older version of the framework.
Monday, February 16, 2015 4:38 PM ✅Answered
I see the other replies you have, and I am 99.971% sure they are speaking of what you are thinking of, which is a label, but in the off chance you're asking about literally "drawing on the form", and not using a control, there is a graphics object which will render text as well. Be advised, it is better to, and the standard practice to use a label, unless you want the user to edit the text, then you would use some sort of textbox.
Example
Option Strict On
Option Explicit On
Option Infer Off
Public Class Form1
Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
Dim g As Graphics = e.Graphics
g.DrawString("Hello world", New Font("Consolas", 12), Brushes.Red, New Point(10, 10))
End Sub
End Class
“If you want something you've never had, you need to do something you've never done.”
Don't forget to mark helpful posts and answers ! Answer an interesting question? Write a new article about it! My Articles |
*This post does not reflect the opinion of Microsoft, or its employees.
Monday, February 16, 2015 5:11 PM ✅Answered
I am a complete newbie to 2008, so forgive me. How do I print text on a form in Visual Basic 2008. Also, I am having trouble finding usable documentation on VB 2008, can anyone recommend some good documentation or tutorials?
Best regards,
Randy Boulter
Text isn't on a Form unless it is drawn onto a Form. Text is usually within a control used for string display.
Doesn't VB 2008 come with help capability? Other than that you probably will need to search the internet using a search engine to find instructional tutorials on the VB 2008 IDE if any still exist. Unless you want information on VB.Net from 2008 which isn't much different than VB.Net from today.
Visual Basic 2008 ref'd.
La vida loca