IDE :: Pass Parameters To A Function Using Delegates?

Feb 8, 2010

Can we pass parameters to a function using delegates

Private Sub UpdateLabel(byval text as string)
If Me.Label1.InvokeRequired Then
Me.Label1.Invoke(New MethodInvoker(AddressOf UpdateLabel))
Else
Label1.Text = text

[Code]...

View 2 Replies


ADVERTISEMENT

.net - Utilize Optional Parameters In Delegates?

Aug 6, 2010

However, I am wondering if there are any workarounds or plans for incorporating this feature into VB.NET in the future?What I'd like to do:

Public Delegate Function Deserializer(Of T)(ByRef Buffer() As Byte, optional ByRef BufferPosition As Integer = 0) As T
'Implementation of a func that matches the delegate'
Class A
Public Function Deserialize(Byref Buffer() as Byte, optional Byref BufferPosition as integer = 0)
....

In the absence of specifying "optional" inside the actual delegate itself, it'd at least be nice to be able to do it in the function implementation only:

Public Delegate Function Deserializer(Of T)(ByRef Buffer() As Byte, ByRef BufferPosition As Integer) As T
'Implementation of a func that matches the delegate'
Class A
Public Function Deserialize(Byref Buffer() as Byte, optional Byref BufferPosition as integer = 0)
....

At least this second way, the functions for the delegate will always have a value mapped to each parameter, although some may come from the function side and not the calling side.

View 2 Replies

.NET 8 List.Find Parameters And Anonymous Delegates?

Oct 7, 2009

I gat a problem in the .NET 2 in VB . I would like to use List(Of T).Find method with parameters. in C# v.8 this task is accomplished by using anonymous delegates like:

[Code]...

View 10 Replies

List.Find Parameters And Anonymous Delegates?

Aug 31, 2010

Impossible in VB.NET 8(?) List.Find Parameters and Anonymous Delegates

View 3 Replies

Use Window Like A Function / Pass In Parameters / Use Window / Get Data Out When It Closes?

Dec 13, 2011

I am creating a window that is a generic keypad for editing numerical values on a touchscreen. I would like to press an 'edit' button to create a copy of the keypad window/bring up a reusable version of the same window (I don't care), but pass in parameters: the old value I'm manipulating, and a title to be displayed above the number pad. I would like the user to be able to type in the new value, then press the 'done' key to submit this value and have it sent back to the main application window into my custom control that contains a text box.(I have the number pad's layout sorted out already; I'm already using a variation on it to set a global password 'access level'. It's getting the information in and out that has me scratching my head.) [code]

View 1 Replies

.net - Understanding AddHandler And Pass Delegates And Events

Mar 17, 2010

I am using AddHandler to wire a function to a control's event that I dynamically create:

[Code]...

This code is generating a run-time exception stating: Unable to cast object of type 'MyEventHandlerDelegate' to type 'System.EventHandler' What am I not understanding about System.Delegate even though AddHandler takes as an argument of type "System.Delegate"? What Type does "EventHandler need to be to cast to a type that AddHandler can accept?

View 3 Replies

Using Delegates To Pass Information Back To UI From Custom Socket Class?

Oct 6, 2010

I am in the process of prototyping a small sockets application, which monitors IT infrastructure (due to in-house financial and deployment restrictions, I am unable to utilise an existing commercial or open-source solution). Basically, I have a server application and associated agent process for communicating heart-beat data to the server. The server application implements a TCP socket class (TCPDevice), which is called from a WinForm. I am aware of the restriction on updating the UI from processes running on separate threads, and that the preferred technique for acheiving this is via the use of Delegates in conjunction with the Invoke method. Having had very little need previously for using Delegates (apart from of course std windows events and the BackGroundWorker control), I am at a loss as to how to do this in the context of my application, and would appreciate some assistance, although it has occurred to me that I could use the backgroundworker for marshalling updates to the UI.

Eventually the application will need to update a grid of devices via feeds from the defined agents, however for the purpose of this exercise simply updating a status bar on the UI will suffice. The section of the code which I believe is relevant to propogating the code to the form is contained in the OnDataReceived method.Below is a code excerpt from the protoype app which should put the above into appropriate context:

Code from the form:

[code]...

View 1 Replies

Dynamically Call A Function With Delegates By Passing A String To A Background Thread?

May 20, 2009

How do I dynamically call a function with delegates by passing a string to a background thread in VB.NET?

Currently my code is this

Public Sub invertImageBK(ByVal image As Bitmap)
Dim snxl As System.ComponentModel.BackgroundWorker = createBW()
snxl.RunWorkerAsync(New ImageProperties(image.Clone, "invertImage", Nothing))

[Code].....

View 1 Replies

How To Pass A Function To A Function Is Functors/function Objects Avaiable In VB2010

Oct 12, 2011

I want to make an numerical integration method with takes in an analytic function and integrate it over a specific interval. For the numerical integration procedure I want to use some procedures in nr.com. The problem is that these are programmed in C++ and they uses functors to pass a function to the integration method. How can I do this in VB 2010?

I want to initialize the function (i.e. set a=1,b=0 for function y(x)=a*x+b) and then pass the function to the integration method. Then when the integration method call the function it only calls the function with one parameter (i.e. x since a,b is already set)

What is the best way to do this in VB2010?I want to make a general integration method where I can pass any single valued function and integration limits.

I have just started using VB, and from what I have found so far it seems like the tools you have is

- to us a delegate for the function
- to use a lambda expression for the function
- send a pointer/adressOf
- to create a function class/structure and submit this to the function

As for now I am most inclined to create a function-class. But I am not really sure how.F.ex. I make different classes for each "uniqe function" I want to integrate, but how can I pass them to the integration function when I need to specify the argument type in the integration-function-call?This seems like a basic problem which applies to many Math operations, so I think it would be very useful to clarify this.

View 2 Replies

Get The GET Parameters And POST Parameters In Just One Function?

Aug 6, 2011

is there a way to get the GET parameters and POST parameters in just one function or Collection in ASP.NET? Like using $_REQUEST in PHP? I'm using VB.NET.

View 3 Replies

Setting A Variable To Accept The Result Of A Function By Calling The Function With Many Parameters

Feb 17, 2011

I'm currently working with a client's VB.Net code, which was developed for them by a small development shop a few years ago and which they purchased and have been maintaining and uprgrading since. This client's primary developer is out on indefinite (likely permanent) medical leave and I'm now filling in until they bring in a full timer (as I'm a contractor here). My current task is to add some functionality to a the VB.Net code they purchased. I'm finding practices and techniques in the code that absolutely baffle me and can't make the code do what I want. I'm starting to wonder if it's me and was hoping to get some thoughts on the code I've encountered.

For example: Setting a variable to accept the result of a function by calling the function with many parameters, clearing the parameters in the function, setting them to some value, calling another function with those new values, then never using the values returned by the functions. I'll add a code snippet in the first comment since this is already getting long.

View 9 Replies

How To Pass Parameters

Nov 27, 2010

If I want to use a FolderItem verb like 'Copy to folder', then I have to somehow supply the name of the folder to which I want the object copied. How is this done. I dont understand how msdn can be so minimal on examples.

View 5 Replies

Pass Parameters To An App. And Use Them?

Sep 5, 2009

I'd like to pass a parameter on the startup of an application, and use it in my code.

Such as passing parameters in C# using the (String []args), then referring to them by args[i] for some i.

View 4 Replies

How To Get Name Of Object And Pass Parameters

Jan 31, 2012

For example if I have a function call like below
Function callingMe()
Exit Function

And my Function call is like below
SomeObj.callingMe('1','2','3','4','5') // Variable number of arguments
Inside callingMe() function, I want to know arguments passed i.e 1,2,3,4,5 and the Object i.e SomeObj in above case.

View 2 Replies

Pass Parameters From MSAccess To My .exe ?

Jan 29, 2009

I've created an exe that is a ticket management system for in-house debugging, etc... It uses the same database that is accessible via MSAccess. In order to create a seamless work environment, one of the supervisors wants employees to be able to see data from the tables the exe uses without actually opening the exe and looking up the record. That's no problem since it's all the same db, but they also want to be able to open that ticket with the click of a button...instead of opening the exe and doing the search themselves, they want to just *click* and have the appropriate ticket open in front of them. I have no clue where to even start to do this....

View 11 Replies

Pass Parameters Through Dataset?

Sep 21, 2009

I have two charts one of residents and another of payments, I want to unite them by a parameter that the user enters to show the result. I have written this

SELECT CasaNum, FirstName, LastName
FROM residents
WHERE (LastName LIKE @LastName)
but when writing this code in the button me the error Me.ResidentesTableAdapter.Fill(Me.Por_apellido_DataSet.residentes, LastNameTextBox.Text)

View 1 Replies

Pass Parameters To A Form?

Aug 6, 2009

Can we have a constructor for a form. so that we can pass parameters to a form ?

View 3 Replies

Pass Parameters To CR In VB 2008?

Oct 12, 2008

I've been trying to pass two parameters to my report using code the two parameters are DateTime type, my problem is crystal report viewer is still asking for the first parameter only and it accepts the second one?! in my report i've used two parameters ?firstDate and ?secondDate as dateTime parameters and used them in selctionformula where the date is between the two paramters.[code]...

View 4 Replies

Pass Parameters With Different Namespaces?

Feb 15, 2010

I have a bunch of methods that do some formatting on data that is contained in a structure. I'm passing the structure to the methods as a parameter. The problem is that the same structure is returned from 2 different webservices depending on the program flow (I did not create these services and cannot change them). So at one point I would be passing WebService1.Service.MyStruct and later I might have to pass WebService2.Service2.MyStruct.

Is there a way I can write only one method to handle both type of parameter? The struct is the same and only differs by namespace. I can overload the methods but I was wondering if there was another way to do this with reflection or something along those lines.

View 3 Replies

Why Does VS (C#) Default Parameters To Pass-by-value

May 11, 2010

Just kind of curious about something: why does VS (vb and C#) default params to pass-by-value?I almost never need or want to pass anything by value. Maybe this is some reflection on the way I code. I would never manipulate a value type param directly; i would just return the new value from a private variable... and I just don't see the need to do the background work all the time to add copies of everything to the stack. Why wouldn't I just about always want to pass-by-ref?

View 5 Replies

Asp.net - Open A New Window And Pass Parameters To It?

Apr 19, 2012

I have a web app which has a listbox of all the available reports for a particular user. I want to open a new page 'ReportViewerPane' when a row is clicked and pass the report name and some parameters through to the reportviewer.aspx I then need to set the ReportViewer controls .reportpath to the correct (passed through) value and set the parameters values (also passed through).

I the moment I have this in the parent page. 'PassParmString' is a textbox on the main form:

function open_win()
{
var Parms = document.getElementById('<%=PassParmString.ClientID %>');

[Code].....

View 2 Replies

Asp.net - Pass Parameters To A Webmethod From Querystring

May 10, 2011

I'm developing a website with ASP and VB.NET 4. I'm also using the FullCalendar jQuery plugin, but I have a trouble: catching a parameter from querystring to the webmethod in the .asmx. I've tried to refer the querystring property with the Request.QueryString() and it doesn't work.

Here's the webmethod:

<%@ WebService Language="VB" Class="wbsCalendario" %>
Imports System.Web
Imports System.Data

[Code].....

View 1 Replies

Can't Pass More Than One Anonymous Parameters In URL Via Ajax

Mar 6, 2012

I'm trying to send some Ids via route values with my data in my ajax call and I'm having issues passing more than one.

This is what I'm having to do now... Then split it out into an array on the server.[code]...

View 1 Replies

Can't Pass Parameters On A OnClick When Using LiteralControl

Apr 11, 2012

I am using the LiteralControl to add some HTML in the codebehind. It's working great and I have added a button, when the button is clicked I want to trigger some JQuery and pass some parameters through. A simply onclick should suffice, now code below works when I DO NOT PASS any values through with the onclick. But the second I try to PASS some parameters through with it (second example) it does not work, anyone know why??[code]

View 11 Replies

How To Pass Parameters To Another Running Application

Aug 18, 2010

we have an old vb6 application (let's call it app-vb6) that basically handles database searches. now i created a new .net application (app-dotnet) that can use the database information to do something else.

what i want to do is to be able to run app-dotnet using information obtained from app-vb6 (which would send something like a command line with a few parameters). but i don't know how to make only one single instance of the app-dotnet to refresh information every time app-vb6 calls it. this link [URL].. seems to have the answer but i could not follow it since it is VC.

View 2 Replies

How To Pass Parameters To Stored Procedure

Jun 26, 2011

This code calls a store procedure that takes input parameters. With this code I'm confused as to how the parameters are passed to the stored procedure. The parameters are first stored into 2 string variables (strCategoryName & strOrderYear). They are then copied/moved to an sql parameter prm.value. But the stored is stored in an sqlcommand (cmd ). I can't understand how the stored procedures knows what the parameter values are.

Private Sub btnWithParameters2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnWithParameters2.Click
Dim cnn As SqlClient.SqlConnection = _
New SqlClient.SqlConnection("Data Source=SKYROCKET;" & _
"Initial Catalog=Northwind;Integrated Security=SSPI")
[Code] ......

View 12 Replies

Pass Additional Parameters To Predicate?

Aug 20, 2010

My issue is to Find exact one Calendar object from a List Of(Calendar) by passing a particular date. I got to know about the predicate but not sure about passing parameter to it.

colorcode is List Of (Calendar) and calendar class has a property called DtmDate with which I want to compare and return the desired object. Dim a As Calendar = colourcode.Find(AddressOf New Calendar.FindByDate)

I got the predicate samples from Google and reached till now. But not sure how to pass my parameter i.e. date to it.

View 1 Replies

Pass Custom Types As Parameters?

Mar 23, 2012

I am calling a XML web service (standard web service project based on .NET 3.5) and trying to pass custom types as parameters. The custom types are defined in my consuming code and the web service references an assembly from the consuming code to get access to the types. The serialization is being handled by .NET.

<WebMethod()> _
Public Function MyMethod() As MyType
Dim myValue as new MyType
return myValue
End Function

In my consuming code I created a web reference to the service and the proxy classes were created. I gave the service the namespace "WebService". Next I try to make a call to the service and assign the result from the call to a variable, something like this:

Dim service As New WebService.ServiceNameSoapClient
Dim response As New MyType
response = service.MyMethod()

I get an error from the IDE saying that it cannot convert type mynamespace.WebService.MyType to mynamespace.Entities.MyType. It appears to me that although the types are similar they are being treated as different because of the different namespaces, which makes sense of course.

Edit: So from what I am reading I believe this is by design, that is the proxy types are simply different types and cannot be directly associated with the types in the consuming code.

View 2 Replies

Pass Custom Types Through As Parameters?

Oct 23, 2011

Today, I'm proceeding with my college work, and am having a little trouble. I'm writing a function, but would like to pass custom types through as parameters, for example Function Game(Section as Game_Section) code here End Function I tried using a structure, but it kept giving me errors

View 13 Replies

Pass Multiple Parameters In Thread In VB?

Oct 25, 2010

I'm looking to pass two or more parameters to a thread in VB 2008.

The following method (modified) works fine without parameters, and my status bar gets updated very cool-y. But I can't seem to make it work with one, two or more parameters.

This is the pseudo code of what I'm thinking should happen when the button is pressed:

Private Sub Btn_Click()
Dim evaluator As New Thread(AddressOf Me.testthread(goodList, 1))
evaluator.Start()

[Code].....

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved