|
-
Apr 6th, 2004, 04:59 PM
#1
Thread Starter
New Member
VB.NET Newbie
I previous projects I used Module.bas to handle most of my code. In VB.NET How do I call these from my forms. For an example
I have a Module called Main.bas and Something.bas. In VB6 I used
Main.DoSomething()
Sonething.AnotherThing()
Also, when I refer to textboxes on the form from the Module I used.
Form1.Textbox1.text = "Hello World."
How would I handle these two examples. Thanks in advance.
-
Apr 6th, 2004, 05:36 PM
#2
Member
Modules are still around in VB.NET, but they have the file extension .vb (Main.vb). To call functions inside your form code, you can just refer to the function name.
For example, if you have a function called DoSomething() in your module, and want to call it just type DoSomething(). No need to refer to the module.
-
Apr 6th, 2004, 07:34 PM
#3
Junior Member
but make sure you declare your function in your bas module at least as Friend
www.mod2software.com
Home of the VB.NET Class Builder Utility - Demo and Full versions available now!
-
Apr 6th, 2004, 09:13 PM
#4
Frenzied Member
to reference another control or another form from your module, you have to declare a variable as that form....
dim form1 as MyMainForm
then, whatever you do to form1 is actually done to MyMainForm
to change the text of a textbox on MyMainForm for example, do this
VB Code:
dim DummyForm as TheMainForm
dummyForm.TextBox1.text = "Van Halen is back, baby!!"
the thing to watch for is scope. read up on that in your help files.
another thing is to not declare it as NEW. that actually creates a new instance of that form and your main one never gets altered.
hope that helps!!
-
Apr 7th, 2004, 08:54 AM
#5
Thread Starter
New Member
Thanks
Thanks to all who replied. This will give me the start I need to move from VB6 to VB.NET.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|