Click here to Skip to main content
15,891,708 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: code documentation Pin
Dennis C. Dietrich26-Nov-04 5:15
Dennis C. Dietrich26-Nov-04 5:15 
GeneralRe: code documentation Pin
Paebbels26-Nov-04 8:34
Paebbels26-Nov-04 8:34 
GeneralCan't set a link to a exe Project Pin
Paebbels25-Nov-04 9:14
Paebbels25-Nov-04 9:14 
GeneralRe: Can't set a link to a exe Project Pin
Dennis C. Dietrich25-Nov-04 9:46
Dennis C. Dietrich25-Nov-04 9:46 
GeneralSending mail Pin
spyatnoon25-Nov-04 8:57
spyatnoon25-Nov-04 8:57 
GeneralCommand button: put text right next to icon Pin
shinay25-Nov-04 7:34
shinay25-Nov-04 7:34 
Generalcall the click event of a button Pin
jlawren725-Nov-04 6:55
jlawren725-Nov-04 6:55 
GeneralRe: call the click event of a button Pin
Tom John26-Nov-04 4:53
Tom John26-Nov-04 4:53 
You need to make the event handler method for the button click on Form2 public and within it check what control it is handling:

    Public Sub Search(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click<br />
<br />
        If sender.GetType Is GetType(Form1) Then<br />
            MsgBox("Button Called By Form 1")<br />
        ElseIf sender Is GetType(Button) Then<br />
            MsgBox("Button Called By Button")<br />
        End If<br />
<br />
    End Sub


Then from the other form you can call this method in the load handler:

    <br />
     Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
<br />
        Dim form1Instance As New Form1 'Only if you don't have another instance<br />
        form1Instance.Search(sender, e)<br />
<br />
     End Sub<br />


Hope this helps, although maybe you want to rethink your design a bit though and have a another class that performs the search that each form could access independently:

<br />
Public Class Search<br />
<br />
    Public Shared Sub DoSearch(ByVal sender As Object, ByVal e As EventArgs)<br />
<br />
        If sender.GetType Is GetType(Form1) Then<br />
            MsgBox("Button Called By Form 1")<br />
        ElseIf sender Is GetType(Button) Then<br />
            MsgBox("Button Called By Button")<br />
        End If<br />
<br />
    End Sub<br />
<br />
End Class<br />


You could then call this from anywhere without even creating an instance of the Search class using:

<br />
Public Sub Search(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click<br />
<br />
     Search.DoSearch(sender, e)<br />
<br />
End Sub<br />



Cheers

Tom
Generalnotepad finding Pin
pranav.net25-Nov-04 6:48
pranav.net25-Nov-04 6:48 
GeneralRe: notepad finding Pin
Pablo.ar25-Nov-04 17:49
Pablo.ar25-Nov-04 17:49 
GeneralConcatenating multiple datatables Pin
JoeContreras25-Nov-04 4:27
JoeContreras25-Nov-04 4:27 
Questioncombo box item values - Possible? Pin
cwayman25-Nov-04 2:21
cwayman25-Nov-04 2:21 
AnswerRe: combo box item values - Possible? Pin
cwayman25-Nov-04 5:35
cwayman25-Nov-04 5:35 
Questionhow to set the backcolor of the colomn header in vb.net Pin
Member 125367924-Nov-04 23:25
Member 125367924-Nov-04 23:25 
GeneralVB.net Setup Pin
nitin_ion24-Nov-04 20:30
nitin_ion24-Nov-04 20:30 
GeneralRe: VB.net Setup Pin
Dave Kreskowiak26-Nov-04 3:31
mveDave Kreskowiak26-Nov-04 3:31 
GeneralLoading bulky XML into dataset Pin
atulpatel_mca24-Nov-04 18:22
atulpatel_mca24-Nov-04 18:22 
GeneralRe: Loading bulky XML into dataset Pin
Dave Kreskowiak25-Nov-04 5:19
mveDave Kreskowiak25-Nov-04 5:19 
Generalserver.mapPath Pin
pyb24-Nov-04 17:31
pyb24-Nov-04 17:31 
GeneralRe: server.mapPath Pin
Dave Kreskowiak25-Nov-04 5:17
mveDave Kreskowiak25-Nov-04 5:17 
GeneralDatabase Management in VB.net Pin
fibman24-Nov-04 13:50
fibman24-Nov-04 13:50 
GeneralRe: Database Management in VB.net Pin
Chaos Machine25-Nov-04 15:52
Chaos Machine25-Nov-04 15:52 
GeneralRequested Registry Access is Not Allowed Pin
KreativeKai24-Nov-04 9:09
professionalKreativeKai24-Nov-04 9:09 
GeneralRe: Requested Registry Access is Not Allowed Pin
Dave Kreskowiak24-Nov-04 10:37
mveDave Kreskowiak24-Nov-04 10:37 
GeneralRe: Requested Registry Access is Not Allowed Pin
KreativeKai29-Nov-04 8:42
professionalKreativeKai29-Nov-04 8:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.