Solved

vb.net call sub with both parameters?

Posted on 2010-09-01
12
386 Views
Last Modified: 2012-06-27
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
Comment
Question by:fsze88
  • 4
  • 4
  • 3
  • +1
12 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 33574913
check this example:dim eargs as EventArgs = new EventArgs 'fill the EventArgs instanceListCom_SelectedIndexChanged(ListCom, eargs )
0
 
LVL 15

Author Comment

by:fsze88
ID: 33575074
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
 
LVL 42

Expert Comment

by:sedgwick
ID: 33575148
why would u pass OnClick to ListCom_SelectedIndexChanged?
why are you calling this sub explicitly anyway?
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 42

Expert Comment

by:sedgwick
ID: 33575226
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
 
LVL 15

Author Comment

by:fsze88
ID: 33575332
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
 
LVL 3

Expert Comment

by:noyshai
ID: 33577131
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
 
LVL 42

Expert Comment

by:sedgwick
ID: 33577171
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
 
LVL 15

Author Comment

by:fsze88
ID: 33578752
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
 
LVL 3

Expert Comment

by:noyshai
ID: 33579015
Can you please try to explain what you want again?
0
 
LVL 15

Author Comment

by:fsze88
ID: 33579037
passing second parameter onclick event to sub ListCom_SelectedIndexChanged(ListCom,"onclick_event")
0
 
LVL 3

Expert Comment

by:noyshai
ID: 33579067
dim myEvent as new System.EventArgs()
ListCom_SelectedIndexChanged(ListCom, myEvent )
0
 
LVL 27

Accepted Solution

by:
Ark earned 500 total points
ID: 33582819
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert an ASPX page into PDF 7 32
VB.NET 2008 Populate DataModel with DataTable 44 28
Regex validation 2 24
VB.NET - Error - Object not set in Module 4 33
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question