CryoEnix Posted November 9, 2003 Posted November 9, 2003 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! Quote Chaos is merely logic beyond human comprehension
Leaders Iceplug Posted November 9, 2003 Leaders Posted November 9, 2003 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. Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
CryoEnix Posted November 16, 2003 Author Posted November 16, 2003 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 Quote Chaos is merely logic beyond human comprehension
*Experts* mutant Posted November 16, 2003 *Experts* Posted November 16, 2003 See if this thread helps you: http://www.xtremedotnettalk.com/showthread.php?s=&threadid=78756 :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.