calling a sub from a different form

crazymarvin

Member
Joined
Nov 22, 2006
Messages
18
Location
Belfast, UK
Programming Experience
Beginner
How do you call a subroutines from a different form? The subroutine I want to handles a text box being changed, and i want it to do the same thing on a different form. I tried
VB.NET:
Call frmOrder.textbox_name_validation
Can anyone help?
 
Hi crazymarvin,

I think you should follow these steps:

  1. 1. Add a module to your current project. E.g. :
    Module Module1
    Public Form1 As New Form1 ' or your other 1st form
    Public Form2 As New Form2 ' or your other 2nd form which contains MySub() you will call
    Sub Main()
    Form1.ShowModal()
    ' Form2 will be called by Form1
    End Sub
    End Module
  2. 2. Open Project Properties, and set the startup object to Sub Main()
  3. 3. Add MySub() procedure to Form1
  4. 4. Call the Form1's procedure from the Form2

Hope this helps!
 
Your call to frmOrder.textbox_name_validation event handler procedure should work (change Form1 to frmOrder)
 
Back
Top