C# To VB: Class.Event += (sender, Args) => FunctionName(params)?
Apr 6, 2011
I'm trying to convert the C# code from this webpage to VB.Everything seems to have converted pretty much fine using an online converter tool, but then I reach the following line:
fadeOutAnimation.Completed += (sender, args) => OnFadeOutAnimationCompleted(d, hostGrid, grid);
The fadeOutAnimation.Completed event produces an event with the signature (sender, args), and d, hostGrid and grid are variables local to the function containing this mysterious event handler assignment.
I think I can see that the instruction on this C# line is telling the code to execute the OnFadeOutAnimationCompleted function, using d, hostgrid and grid as parameters, when fadeoutAnimation.Completed occurs, but I have no idea what to even search for in order to replicate this behaviour in VB.net.
View 5 Replies
ADVERTISEMENT
Oct 28, 2009
Perhaps surprisingly I haven't added an event handler programatically before and I'm having trouble getting my head around AddHandler.I am creating a series of DataGridView controls in a loop and want to subscribe to the CellFormatting event on each of them.The event handler signature is as follows;Private Sub ConfigureRows(ByVal sender As System.Object, yVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs)This works fine when I enter it in the visual editor properties box but I can't figure out how to give it the correct arguments using AddHandler.
View 2 Replies
Feb 9, 2011
When I write public events for my business objects, I've adapted the habit of always passing the instance as "sender as Object", in addition to additional specific parameters. I just asked myself now why am I not specifying the class?
So for you with more experience; Do you ever pass the distinct class as sender in an event? And if so, what are your decision criteria for when this is ok/not ok?
View 8 Replies
Jun 25, 2009
I fully realize that what I am proposing does not follow the .NET guidelines, and, therefore, is probably a poor idea for this reason alone. However, I would like to consider this from two possible perspectives:
(1) Should I consider using this for my own development work, which is 100% for internal purposes.
(2) Is this a concept that the framework designers could consider changing or updating?
I am thinking about using an event signature that utilizes a strong typed 'sender', instead of typing it as 'object', which is the current .NET design pattern. That is, instead of using a standard event signature that looks like this:
[Code]...
View 11 Replies
Nov 25, 2011
Heres my sub:
Dim onThisTable as String ="Name"
Private Sub skill_mouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.MouseHover, button2.MouseHover, panel1.MouseHover, panel2.MouseHover, pbox1.MouseHover
[Code]....
Now I wish to give onThisTable a different value depending what the user pass over (panel or a pbox or a button) but I cant find what is the correct way to compare what type it is ...
Private Sub skill_mouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.MouseHover, button2.MouseHover, panel1.MouseHover, panel2.MouseHover, pbox1.MouseHover
[Code]....
View 1 Replies
Jul 8, 2009
Is it possible to have a sub that is triggered when any control of a specified type is clicked (or some other interaction), and then within the code of that sub, determine the sender and depending on the sender perform an action?For example, you create buttons dynamically, and assign them a name based on a counter that tells the number of buttons on the form. Now you click on a button, but there was no code written for 'button123.mouseclick' specifically. Instead, you get the name of the sender (button123) and you do something specific to that button.[code]
View 5 Replies
Feb 23, 2009
I have a list of objects, each with several events. I can add an eventhandler to each object, so I can catch each item's events. But I would also like to know the sender's index in the list (ie, was this object the 3rd, 5th, etc, item in the list?) I'm guessing the object doesn't "know" its position.I could give each object an index number property when it is created and added to the list, so that information could be passed. However, I would have to reindex every item everytime I use remove, insert, etc, methods.
View 4 Replies
Dec 4, 2009
I have a MDi project , I want to raise the activated(Sender, eventArgs) event of activeMdi Form
View 5 Replies
Aug 13, 2011
(me = an absolute beginner in WPF / VB2010) how to get the type of sender in (ByVal sender As Object)? Purpose: when two different Objects call the same subroutine, find out which one actually called it.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
sayHello(sender)
End Sub
[code]....
View 5 Replies
Jan 19, 2012
following code from c# to visual basic, and I'm coming up with the following error: 'Public Event ItemCheck(sender As Object, e As System.Windows.Forms.ItemCheckEventArgs)' as an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
[Code]...
View 8 Replies
Dec 27, 2010
Is it possible to raise event in one class and handle the event in another class? If so, how?
View 6 Replies
Nov 18, 2010
I have a class that is stored after serialization and compression.Is there any event built in the class that is fired automatically when a class is deserialized and ready to be used??
View 1 Replies
Oct 8, 2011
When debugging my app it works fine i.e. It gets the two commandline args, through a loop, and execute as expected. However, once I publish it, the app only picks up the first argument, which is the .exe file string. Code below:
Public Sub Main()
Dim args() As String = Environment.GetCommandLineArgs()
Dim n As integer = args.Length
[Code]....
View 7 Replies
Apr 14, 2009
I have a "partial" class in VB.NET. Half of it is auto generated by a code generation tool. That half implements INotifyPropertyChanged, so any properties in that part of the partial class raise the PropertyChanged event.In my "custom" part of the class, I declare another property that depends on one of the properties in the auto-generated side. Therefore, when that auto-generated property changes, I also want to raise a PropertyChanged event on my custom property that depends on it.
If I go into the generated part of the class and raise the event there, that will get overwritten if I ever re-generate that part, so I don't want to do that. I would rather add an event handler in my side of the partial class that checks if the generated property changed, and if so, raise another event for my custom property.
[Code]...
I'm assuming it's because normally you'd use the WithEvents keyword to tell the compiler that you're subscribing to events from that object. I don't have a clue how to do this inside of the class that's actually raising the event, or if that's even possible.
View 1 Replies
Mar 30, 2012
I'm looking at an old module to add some new features. I noticed this in a subroutine declaration:sub foo(...,optional fum as integer = 0)the later if not isnothing(fum) then <do something>I'm wondering, will <do something> ever be executed? I'm guessing not, since fum has a default value, but I want to be sure I'm getting this correctly.
View 12 Replies
Jan 8, 2009
Let's say I have a console application that performs some actions on text files. I'd like a way to, in Windows Explorer, select multiple files, then hit a function key (or something like that) which launches my application using the selected file names as it's input parameters.
View 1 Replies
Aug 9, 2011
I'm creating an inherited class like this:
Public Class MyClass1
Public Sub New()
MsgBox("No Args")
[Code].....
Why does the MyClass1 new() method (no args) get executed when I am instantiating the zzz class and passing in a string ?
View 3 Replies
May 1, 2011
I might be alone in this; but I was always under the impression that in .NET when you called a function you had to pass in values in the same order as the method.[code]I've ever seen just calls the method with the params in the correct order - is the named convention an old left-over from VB? If I were to use the := syntax in all my method calls, would people laugh during my next code review?
View 2 Replies
Aug 17, 2009
I have a old vb6 application I maintain,that has the settings in a separate xml file.
But now I have to move those "inside" (to remove the xml, don't ask why :) ).
What would be best place/"paradigm" for such
settings to be handled in vb6 Like database connections, general parameters. Also to be easy to change it, u know what I mean. I just searched on the web but until now could not find it. Of course it is easy to hard code the ones for the moment
View 2 Replies
Nov 16, 2009
What I am wanting to do is pass some information from my app to a new DLL project I have created. In the DLL I have 2 test forms (frm123, frm456). What I need to do is send 2 parameters over to the DLL, when the DLL recieves the info it would then determine which form to open. In the DLL I have in the Main Module ' I will use arg(0) later
[Code]....
View 18 Replies
Apr 20, 2010
I'm having an issue with an application suite I'm developing. The bulk of the work is done in a backend dll that relies heavily on delegate subs in the different apps.
The problem I'm having is, I have a lot of these delegates typed to require a parameter. (eg, Public Delegate Sub DelTypeA(ByRef param As Object)). The individual methods will have a DelTypeA as one of their params, and I will pass it AddressOf functionA that has that signature.
This works fine for strong typing as long as the signature is something incorrect (2 params, a byval instead of a byref). But if functionA has NO params, the delegate is still created!
This works fine if I genuinely don't need to use a param, eg if the sub is simpler and I would have ignored the param anyway. But I want the strong typing to work here.
EDIT: I should add that invoking the delegate also works fine for simpler subs; the param is just not passed because it had nowhere to go. But I want to force all the subs to match the signature and do their own ignoring of the param
View 1 Replies
Jun 2, 2010
[code]...
Is there any issues with this? If I'm kicking off half a dozen threads over and over? ie: I'm not using a system where the parameters will get mixed up/corrupted?
I've looked around, and if this is OK/safe to use, this seems the easiest way to get values/params into a thread.
View 5 Replies
Jan 11, 2009
I was going over the Screen Saver Tutorial for VB Express 2005 and i Noticed How the Screen Saver app excepts params at startup... and depending on the startup param it will display the screen saver or the options form... lets say that i want to start up a screen saver from my program, how would i send it to the screen saver to display the options form the param is "/p" or something.
View 2 Replies
Jun 23, 2010
My first post as an absolute last resort. In 8 years of programming, I have never posted to a programming forum and have always been able to wiggle my way out of any diffficult project...Until this project.Every step of this project is new for me (Windows service, ini file, IIS, FTP, cmd line params, comparing file specs programmatically, using a timer, and even VB.NET is still confusing to me after several years in VB6 ). Dreading posting b/c I have so many questions. I have finished the internet, been to the end and back. Found endless suggestions of code and links and forums and only gotten more lost in the process.
I am trying to create a VB.NET app, that most likely will need to be a service, for our external clients' PCs. These PCs are not connected to our network. This app will be invisible to the user and will need to perform several tasks including:
[Code]...
View 1 Replies
Dec 23, 2009
Finding the documentation on windows API's for use with visual basic? I used to use API guide until they stopped updating it in 2002. All I need is the api name as well as the list of parameters in order to use the API's functions.
View 2 Replies
Feb 24, 2012
I am currently facing an heavy struggle with architecturing my VB.Net app.To simplify, i'm using entries from XAML comboboxs, which all trigger OnChange the same routine which manages which Function(s) to use depending on which combobox triggered.The problem i'm facing is for example i have Function(ByVal A As String, ByVal B As Integer, ByVal C as Double, etc...), and it works if the routine calls explicitly for this function's result. But then if another combobox makes for example the variable B to change, then i have to add another "If sender= Then" check for this combobox and recall expicitly the function above (since B is one of its parameters)..In the end, my routine is loooooong like 24 checks with at least 4x duplicates of same functions..is there a simple way to make a Function autoexecute when one of its parameters change without having to be called explicitly by another routine ? (Like Excel formulas do when one of its references change)
View 12 Replies
Sep 16, 2010
This illustrationshows 4lines of arguments usedforprojectis run in Debug mode.
View 3 Replies
Oct 21, 2010
I'm converting some RDO code to ODBC Provider code in .NET.The problem is parameter names were not specified in the orignal code, but param values were retrieved by parameter name after the command was executed.Is there anyway to have parameter names populated by the provider once the command is executed so calling code can access params by name.Let me show you an example of the declaration of param and accessing of it.
[Code]...
You can now see how this "used to work in RDO/VB". For some reason it would accept this and know what the param names were after execution. I imagine it had to do another round trip to the db to get this info.
Is there anyway to mimic this behaviour in .NET for ODBC Provider (using Oracle)? Or am I stuck manually specifying the param names in the code (I understand this is the better option, but wondering what the alternative is to match the original code as closely as possible).
View 1 Replies
Sep 24, 2009
I would like to pull a set of records in a SQL sproc by passing in a list of system.guid and also by passing in a list of integer keys.I can put the guids ihto a string, of course, but the question is - how do I quote the test values so they are recognized as UIDs by SQLIn essence I was to DECLARE @pklist AS VARCHAR(1000)-- This would look like "'45F4AE2A-D27C-D711-83FD-0008C7FA9683','EC824D02-D37C-D711-83FD-0008C7FA9683','BA8E4D02-D37C-D711-83FD-0008C7FA9683'" coming out of the execsql from vb .net - I think :-) but it seems it needs to look likeSET @pklist = '45F4AE2A-D27C-D711-83FD-0008C7FA9683,EC824D02-D37C-D711-83FD-0008C7FA9683,BA8E4D02-D37C-D711-83FD-0008C7FA9683'SELECT * from dbo.members WHERE members.cpk IN (@pklist)This only returns the record matching the first UID in the string. Is there something I can wrap a t-sql VARCHAR string with so each guid will be seen distinctly?In trying to do this with a list of integer keys, the problem is the value is seen as part of a string and is not cast to an integerIt would seem creating a table from a parsed version of the string passed in and then doing a JOIN would accomplish what I need as well, but struggling with the T-SQL syntax for that.
View 1 Replies
Apr 24, 2010
I know how to call a simple old fashion asmx webservice webthod that returns a single value as a function return result. But what if I want to return multiple output params? My current approach is to separate the params by a dividing character and parse them on teh client. Is there a better way.
[Code]...
View 2 Replies