Pass A Function As An Object Instead Of It?

Dec 20, 2011

I'm trying to give a default value to the register property method. This required a function, but passed as an object(delegate?).[code]....

I want to call that registerproperty method, but I don't know how I can do that in VB.net. I just need to pass along a new Person object and I thought this was the way to go[code]....

View 3 Replies


ADVERTISEMENT

Function - Pass Object Versus Reference Object In Parent?

Dec 1, 2011

I am working on a application that has quite a few functions involved and have been thinking of the following: If I have a function that has a few paramaters, is it more efficient to pass the objects to the function(Example 1) or reference the objects in the parent(Example 2)? Does it matter if the objects are large or not?

Example:

Class mainform
Public myGenericList As New List(Of String)
Public myDatarowArray() As DataRow

[Code].....

View 6 Replies

Pass Object To Function Using CodeDom?

Jun 27, 2010

How do you pass a control (say a textbox) to a function as a parameter in compiled assembly using CodeDom? I've tried passing through the args in the Invoke method but it doesn't work.[code]...

View 6 Replies

Pass The Property Of An Object To A Function ByRef

Jul 16, 2009

If you pass the property of an object to a function ByRef, and the function doesn't modify the ByRef parameter, the property Set is still called.

[Code]...

View 11 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

In .net, If A Function Returns An Object, Is It Wrong To Just Use The Function, _as_ An Object

Apr 30, 2009

I've got a f(x) that returns a collection of user controls. .Net lets me just treat the f(x) name as the collection.

ex)
Private Function GetCcB() As Collection(Of Reports_ucColumn)
Dim cc As New Collection(Of Reports_ucColumn)
cc.Add(Me.ucColumn0)

[code].....

View 3 Replies

Pass Function (Of TElement / TKey) As A Function Parameter

May 28, 2012

I want to make a GetAllContacts method which takes a sort parameter of type Func(Of Contact, TKey) which is the same type that the OrderBy method for an IEnumerable(Of Contact) takes.[code]"Too many arguments to extension method 'Public Function ElementAtOrDefault(index As Integer) As Contact' defined in 'System.Linq.Enumerable'." on the second parameter.

View 2 Replies

Pass A Value From A Sub Procedure To A Function Procedure .... Pass The Whole Subprocedure To The Function Procedure Argument?

Mar 30, 2012

Im a student doing an assignment, how do i pass the value from a sub procedure to a function procedure....i want to pass the value from decSubtotal to a function procedure named CalculateDiscount; check out my code--

[Code]...

View 1 Replies

Object Reference Not Set To An Instance Of An Object When Calling A Function

Jun 13, 2012

I call the function GetDataTable and when it gets to the return line, I get the error message: Object reference not set to an instance of an object.

Dim DB As New DBConn
Dim gd As New DataAccess.GetData
Dim DT As New DataTable

[Code].....

Updated. I'll see if I can update with the DataAccess.GetData code. I didn't originally put it in there because our shop use it all the time and have no issues with it.

View 1 Replies

How To Pass Object As Sub

Jan 20, 2012

This code copose from Class including tow sub first sub to insert data in DB Ms access- second code: to check if there is same number of Tel if there is not same number will excute the first code insert, if there is same number of Tel it will show messagebox the problem that I faced is by how to pass object(InsertData) from CheckN sub. It showed me error : Expression is not a method

[Code3]...

View 1 Replies

How To Pass Parameter For Function

Dec 9, 2009

I have a statement:
dat.XoaNhanVien(Me.dtgcapnhatthongtin.CurrentRow.Cells(1).Value, message)
That is a function for deleting info. Now I want to create other function and get above function to parameter. I mean:
Public Function func(Byval func as " What type can be ?")

View 13 Replies

Pass A 3D Array To Function?

Nov 20, 2009

I want to pass the entire array to the next function[code]...

View 3 Replies

Pass A Bitarray To A Function?

Sep 14, 2011

I'm trying to pass 2 bitarrays to a function that ANDs the bitarrays and returns the count of bits that are set to TRUE. However, something strange happens when I reference the bitarray from within the function and the results are non-sensical.

So I have output the bitarray contents before it is passed to the functionand they match the source data, then I output the contects of the bitarray from within the functiona and they are completely different.

View 3 Replies

Pass A File To A Function?

Mar 6, 2009

I'm working on a VB.NET DLL right now, and one of the functions I'm writing is supposed to take a file, and clip out an array of bytes (the method I've got works, and can be abstracted away here). What's the best way to pass a file to this function? Would passing a filename to it be best, or what would be the best way to accomplish this?

View 2 Replies

Pass An Expression Into A Function?

Jun 10, 2011

I just want to ask if it is possible to create a function that accepts an expression into its arguments. Just like what IIF do. Ex: Dim strResponse as String = IIF(Msgbox("Select Yes or No", vbYesNo) = vbYes, "Yes", "No") I forgot the code, but its the thought that counts.

View 1 Replies

Pass An Operator As A Value On A Function?

Jun 27, 2012

The is a calculate function for example Function Calculate (Byval v1 as integer, Byval v2 as integer, byval op as ????????) as double return v1 op v2

End Function Anybody tried this?

I don't want to use functions for every operation (multiply,divide, etc.). I wanna pass a operator same as I pass the values. How come nobody ever had this need in VB? Using enums could work but still...

View 1 Replies

Pass Array Value To A Function?

Jun 12, 2009

i need to pass array value to a function , here are the details

function MyTest(byval a as integer, byval b() as string)
if b is nothing
msgbox("no array")

[Code]......

View 3 Replies

Pass Arrays To A Function?

May 18, 2009

I have an array of integers and I want to pass the array to a function that will add up the elements of the array and return the cumulative total of the elements of the array. So, if the array contains the values {1,2,3,4,5} the return value from the function would be 15.

View 2 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

Make An Object Not Pass Through Another?

Apr 5, 2012

I am making a simple maze game that you use the arrows keys to navigate. I completed the movement part of it, but now i'm having trouble with the walls. How can you make an object not pass through another and how to tell the program what to do when a object gets to a defined place(the finish)

View 4 Replies

Object Must Pass Itself As A Parameter?

Sep 10, 2011

I have various shape objects, and I want each unique shape to implement a saveToDB method that simply calls a DB object that implements a Save method with an object as its input paramter. This DB.Save method will be a long case function that implements the proper SQL commands based on the type of attributes possessed by the input parameter object.how do I implement the SaveToDB method in my Shape class? Is it something like this:

Function Shape.SaveToDB
DB.Save(Me)
End Function

The goal here is to let each shape save itself without it knowing anything about database operations; I want to isolate db-specific information in my intermediary DB object, so the DB object will have to figure out what type of object wants to be saved into the SQL database and then execute whatever SQL instructions are needed. And then if I override the SaveToDB method in each shape subclass, I can avoid the case statement entirely, replacing it with a series of unique methods such as db.SaveCircle (ob), db.SaveSquare (ob), etc., sincle the caller already knows what it is.

View 4 Replies

Pass Data Out Of An Object?

Dec 17, 2010

I have this [code]...

1. Create a global SQL instance and call .Write from within .ReadData

2. Create a new SQL instance within .ReadData and call .Write

3. Pass the data back to the code above and call .Write from the main code i.e. [code]...

View 1 Replies

Pass Object Between Asp.net Applications?

Jan 6, 2012

We have a few applications that will be passing a token object around and I wanted to get an idea about the best approach at doing this.

For starters, this token object is somewhat simple. It would have about 5 properties or so.

Would we create a WCF app and reference it through a datacontract?What about serializing it and sending it through an http post? (each app have a referenced dll of the object)Querystring? (I truly don't think this would be good, but put it up nonetheless)?

View 2 Replies

Pass Out An Object Array In .NET?

Mar 25, 2011

I'm writing a wrapper class to expose a subset of the functionality of a .NET FTP library edtftpne from Enterprise Distributed Technologies.

When you call the edtftp's GetFileInfos method you get an array of FTPFile objects returned. I'm able to iterate through these but I don't know how to pass them on as a new and different object array containing only Name and Size for each file. Here's the code I have. Sorry it's a little confusing because I have my own class named FTPFile and the .NET library I'm using also has a class named FTPFile. I'm using both of them here. I should probably change the name of my class just to avoid confusion:

Public Function GetFileList() As FTPFile() Implements IFTP.GetFileList
Dim ftpfiles() As EnterpriseDT.Net.Ftp.FTPFile
ftpfiles = fCon.GetFileInfos 'Fill object array

[Code]....

I'd just pass on the object array that I'm getting from the GetFileInfos method but COM clients won't have access to the class/object EnterpriseDT.Net.Ftp.FTPFile without me rewriting it, I'm assuming.

View 1 Replies

.net - How To Pass Linq To SQL Types To A Function

Aug 27, 2011

The code below is used in a Linq to SQL solution, and is in the Load event of a form. It works fine to display an ordered list of people's names, and set the value member to that person's ID. However, I'm going to be using these 'people' comboboxes a lot, so I'd like to put a sub into my Utility code there is only one line in the form's Load event.

I want to call something like: Call ComboboBoxPeople(cbo, tblTurnbackMain, ReportedByID)

The sub would begin like: Public Sub ComboboxPeople(cbo as Combobox, tbl as 'sometype', fld as 'someothertype')

What can I use as the parameter types for tbl and fld?

[Code]...

View 1 Replies

Asp.net - Number Of Variables Pass To Function?

Dec 5, 2011

if this is a dumb question. I don't ever have to write anything in VB.NET.But I am passing variables named "name" to a function and sometimes it may be 1 name or 2 names, etc. I want to check in the function if its only 1 name don't add a comma, if it's 2 names add a comma. Is there a way to get how many "names" there are?

EDIT: Added my ode to make my question a little more clear. sorry for not doing it before.

My Code:Public Function GenerateCSV(byval str as string, byval str1 as string, byval str2 as string, byval GrpName as string)

[Code]...

View 4 Replies

C# - Pass Whole ListView Row And Use It In External Function?

Jul 21, 2010

I have Listview which databound to Dataset with about 20 items per row. I have a function which executes on each ItemTemplate appearance and gets about 10 params from Eval("something"). So basically one function builds and image from 10 parameters.Instead of passing 10 Eval("something") to the function is it possible to pass it whole row and how to use this row inside of function because it is not simple DataRow or ListView row which i can access as array of items (datacolumns).Reason i do that because function looks ugly and each time i need to change it i need to deal with dozens of items.

View 2 Replies

How To Pass Array Variable From Vba To Function

Mar 3, 2012

Im having a very difficult time trying to pass an vba array ive built from ms- access vba to a .net function.I don't have a com problem I can reference the library just fine from vba but and i can call a simple function from vba. however my problem exist when i attempt to try to pass an array to the vb.net function. vb.net code

View 3 Replies

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

Increase Variable Each Pass Through A Function

Jul 8, 2009

I have a variable that I am trying to get to iterate up by one, i.e. X starts at 0 x+1 on first pass thererfore its at 1 then x+1 on second function call therefore x=2 and so on. I've tried the different loop and for commands but I cant get one to stay until the next function call, does it need to be a global variable? I'm sorry if this is in poor form or improperly formatted, definently trial by fire going into the object oriented world.

View 9 Replies







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