Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey guys, I recently ported over from VB6 to VB.NET. I'm having a few problems with the syntax. I have a module, and in it I need to change the property of a label in another form. In VB6 the code would be something like this:

 

Form1.Label1.caption = "Yay, it worked!"

 

But how would I got about this in .NET? it won't work! Grrr!

Chaos is merely logic beyond human comprehension
  • Leaders
Posted

You need to make a reference to your form available in the module:

Define a public variable in your module of the same type as the form you are using.

When you create your new form from Sub Main, just set this public variable in the module to a new form, and then, you can set the label caption from there.

Dim F1 As Form1
'At the top, before any methods.
Sub Main()
Set F1 = New Form1
F1.Label1.Caption = "Iceplug"

:) Something like this should work.

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Posted

Cheers Plug, but it doesn't seem to work. I've been looking at the 'Auto' window as the program runs and, although the variable changes in the code, it is displayed as red - and it doesn't change on the object!

Is it me, or is VB.NET looking awkward?

auto screen.bmp

Chaos is merely logic beyond human comprehension

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...