[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 408
  • Last Modified:

vb.net call sub with both parameters?

Hi

I can call this sub by
call ListCom_SelectedIndexChanged(nothing,nothing)
But would I able to call this sub with both of parameters?

ListCom_SelectedIndexChanged(ListCom, "event.onclick")
I missunderstand how to call "onclick" event on second parameter?

Thank you!
Francis SZE
Private Sub ListCom_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles ListCom.SelectedIndexChanged
        rsCusObj.MoveFirst()
        rsCusObj.Move((ListCom.SelectedIndex))
        loadRecordSet()
    End Sub

Open in new window

0
fsze88
Asked:
fsze88
  • 4
  • 4
  • 3
  • +1
1 Solution
 
Meir RivkinFull stack Software EngineerCommented:
check this example:dim eargs as EventArgs = new EventArgs 'fill the EventArgs instanceListCom_SelectedIndexChanged(ListCom, eargs )
0
 
fsze88Author Commented:
Hi,
I want to passing onclick into eargs ?
Could you please guide me?
if possible guide me how is onpress, onmouseover events into eargs?

Thank yoU!
Francis sZE
0
 
Meir RivkinFull stack Software EngineerCommented:
why would u pass OnClick to ListCom_SelectedIndexChanged?
why are you calling this sub explicitly anyway?
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
Meir RivkinFull stack Software EngineerCommented:
you not using the eventArgs passed to ListCom_SelectedIndexChanged anyway to better practive will to create another function which will have the current implementation of ListCom_SelectedIndexChange.the you can call this function from anywhere in your code.
Private Sub ListCom_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles ListCom.SelectedIndexChanged
DoUpdate
    End Sub


private sub DoUpdate()
        rsCusObj.MoveFirst()
        rsCusObj.Move((ListCom.SelectedIndex))
        loadRecordSet()
end sub

Open in new window

0
 
fsze88Author Commented:
Hi,
I want to enable to passing second parameter System.EventArgs into sub ListCom_SelectedIndexChanged
cause it may be useful in later on.
Also, that's what I want to learn....

Thank you!
Francis SZE
0
 
noyshaiCommented:
Your sub:

Private Sub ListCom_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles ListCom.SelectedIndexChanged

Doesn't use the variables eventSender and eventArgs that are sent into it, therefore the value of those vars is not important and you set their value to Nothing.

If the vars were read then the value of Nothing could cause an error.

In conclusion: You can call ListCom_SelectedIndexChanged(nothing,nothing) as long as the variables aren't in use.
0
 
Meir RivkinFull stack Software EngineerCommented:
so what u can do is put a breakpoint in the ListCom_SelectedIndexChanged and change index in the list to make it stop there (debug mode).
look how the EventArgs is essemble and use the same properties but crate them dynamically.
0
 
fsze88Author Commented:
the goal of this question is passing second parameter event.onclick to ListCom_SelectedIndexChanged(ListCom, "event.onclick")
ListCom_SelectedIndexChanged(nothing,nothing)  is works on this sub.

my goal is handling while second parameter eventargs would be needed.
sorry!
Thanks
Francis
0
 
noyshaiCommented:
Can you please try to explain what you want again?
0
 
fsze88Author Commented:
passing second parameter onclick event to sub ListCom_SelectedIndexChanged(ListCom,"onclick_event")
0
 
noyshaiCommented:
dim myEvent as new System.EventArgs()
ListCom_SelectedIndexChanged(ListCom, myEvent )
0
 
ArkCommented:
Create your own class derived from EventArgs, add properties you need
Here is an example: http://msdn.microsoft.com/en-us/library/system.eventargs.aspx
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now