Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a SubRoutine from another

Status
Not open for further replies.

Sidrp

IS-IT--Management
Jun 4, 2003
44
0
0
US
Hi Fellows..
Heres wht I am trying to do..
I have two buttons in my form.
1. Add to database and print
2. Just Print

I have the codes written for both, Heres wht I want to do, whn you click Button 1, it shd execute the SubRoutine 2 and then its own statements as the second subroutine is just a sub-set of the first one I dont want to repeat code.

This is how the code looks

Sub btnSubmit_Click(sender As Object, e as System.EventArgs)
Call btnPrint_Click
.....
....
....
end sub

Public Sub btnPrint_Click(sender As Object, e As System.EventArgs)
.....
.....
.....
end sub

I need to know how to call the second sub from the first (Correct syntax implementation) given that both are button click events and are linked to respective buttons by onClick event.

Your help will be greatly appriciated..
thanks
Sid


 
Though you CAN call the event handler, the best way is to just do something like this:

Code:
Sub btnSubmit_Click(sender As Object, e as System.EventArgs)
   Print()

   'etc
End Sub

Public Sub btnPrint_Click(sender As Object, e As System.EventArgs)
   Print()
End Sub

Public Sub Print()
   'blah blah
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top