|
-
Jul 26th, 2006, 05:03 PM
#1
Thread Starter
New Member
[RESOLVED] How to run a sub on another form?
Is there a way to run a sub on a form by calling it from another form?
-
Jul 26th, 2006, 05:45 PM
#2
Hyperactive Member
Re: How to run a sub on another form?
If you declare the Sub public, you can call it from anywhere. Ex:
VB Code:
Public Class Form1
Public Sub HelloWorld()
MsgBox("Hello World")
End Sub
End Class
Say we want to call it from Form2:
VB Code:
Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim frm1 As New Form1
frm1.HelloWorld()
End Sub
End Class
Unity Programs™ - Downloads To Make Your Computer Life Easier - UnityPrograms.com, check it out
My small company, I need feedback.
If someone's post was useful, don't forget to Rate It by clicking the Rate This Post link under the avatar.
If this post has been resolved. Please mark it as Resolved by going through the Thread Tools above and clicking on the Mark Thread Resolved option.
We ride together, We die together, .NET for life. - Working With Visual Studio.NET 2005
Application Deployment, General Developer Forum, Visual Basic .NET
-
Jul 26th, 2006, 06:12 PM
#3
Re: How to run a sub on another form?
Forms are objects, just like any other. Any object can call any accessible member of any other object PROVIDED that it has a reference to that object. Forms are no different. I suggest that you read the "Forms in VB.NET" tutorial in my signature.
-
Jul 28th, 2006, 02:37 PM
#4
Thread Starter
New Member
Re: How to run a sub on another form?
thanks for the help both of you.
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
|