Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I want to execute the code below.
Public Sub CreateMyLabel()
' Create an instance of a Label.
Dim label1 As New Label()
' Set the border to a three-dimensional border.
label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
' Set the ImageList to use for displaying an image.
label1.ImageList = imageList1
' Use the second image in imageList1.
label1.ImageIndex = 1
' Align the image to the top left corner.
label1.ImageAlign = ContentAlignment.TopLeft
' Specify that the text can display mnemonic characters.
label1.UseMnemonic = True
' Set the text of the control and specify a mnemonic character.
label1.Text = "First &Name:"
' Set the size of the control based on the PreferredHeight and PreferredWidth values.
label1.Size = New Size(label1.PreferredHeight, label1.PreferredWidth)'...Code to add the control to the form...
End SubBut it requires System.drawing namespace to be added to the Form containing this code. Can I get some help about adding a namespace to a Form (Visual Basic)

To add a namespace just add the following lines of code to the very top of your page (before the class opens)
Imports xxxx
in your case it would look likeImports System.Drawing
Class MyClass....

Hi Mathew,
Thanks for helping. But I could not use "Import System.Drawing" in VB. I included this statement in my VB form(which is the only form in the project) and also in a class(build with class builder), but it's showing error for the keyword "Import". Can you please be a bit specific about how to use this statement in a VB project? Waiting for your answer. u can mail me at bahar_ul_alam@yahoo.com or post a message here, as you wish.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |