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


ADVERTISEMENT

Pass In An Operator?

Jul 4, 2010

Is there any way to pass in an operator in VB.NET? I'm looking to reduce my lines of code and for two functions there is literally only an operator that is different.For example, I have two functions, Darken and Lighten. I'd like to get to a single function with as little code as possible. The only difference are Greater Than and Less Than operators.

Function Darken(ByVal clr1 As Color, ByVal clr2 As Color) As Color
Dim newR = If(clr2.R < clr1.R, clr2.R, clr1.R)
Dim newG = If(clr2.G < clr1.G, clr2.G, clr1.G)

[code].....

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

CLR - Function/Operator Without Return Value?

Sep 4, 2009

I've create a new project, and set treat all warnings as errors in the compile tab.All the other warnings seem to be treated as errors, except the one which I'm interested in "Function/Operator without return value".I have a simple function within a class, which does not show an error if I do not add a return statement to that function. I have read in many places that VB.Net returns a "hidden" default value if the returns statement is forgotten.My software went out to production where an overloaded function was missing a return statement, which wasn't highlighted due to the above.

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

Visual Studio Documentation Should Have Examples For Every Method, Function, Event And Operator?

Dec 17, 2009

It is really too bad that Microsoft (who once had the best documentation in the business) has slipped so badly. Good documentation does not really require analysis, though, admittedly, it is a lot of work. To wit: for each and every single method, function, event and operator provide the following: a brief topical functional description including any parameters, a detailed description of how the object works, a workable example of the code needed to make this object do something useful and links to all possible associated objects (See Also).

I see pages upon pages of useless text and links to other pages full of links. This rapidly descends into a crevace of unbelievable complexity for the developer trying to find out something truly simple like filtering a DataGridView without changing the data connection. (As it turns out this is very simple to do but I could not find a single example of how to do it in the Visual Studio documentation.)

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

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

.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

Pass A C++ Callback Function To A .NET Program?

Oct 1, 2011

I'm trying to pass a callback function from a C++ dll to a VB.NET application.Here is my current C++ code :

void DLL_EXPORT registerEvent( void (*callBackFunction)(string str),string str)
{
callBackFunction(str);
}
void test(string str)

[Code]...

View 1 Replies

Pass A Form As A Parameter In A Function/Sub?

Mar 23, 2010

Can I pass a form as a parameter in a sub like public Sub GetData(Byval Frm as form) and access its controls?I have few forms (you can say: FrmAccounting, FrmEngineering, FrmIT) with almost the same controls in each of them (txtEmployeeID, txtEmployeeName, optMale, optFemale etc), where no two forms are open at same time, and each of those forms have a Button which opens a new Form (you can say FrmCollectData) now I want to fetch data in FrmCollectData depending on which form it was opened from.. like if user was on FrmEngineering and it clicks button to open FrmCollectData.. form collectData fetches data from FrmEngineering Controls and if user was on FrmAccounting and it opens FrmCollectData, form Collectdata fetches data from FrmAccounting..

earlier, in VB6.. In one of the Sub written in frmCollectData I checked which form is opened by setting flags in each of forms (frmEngineering, frmAccounting etc) and then I passed the same form in a sub which writes data in frmCollectData controls.. but am not able to do the same in VB.NET.

View 5 Replies

Pass A Function To A Class To Be Called Later?

Dec 11, 2010

Okay so what im trying to do is make a simple particle system in VB (Yes i know this isnt a ideal setup). Im going to have particles dieing and spawning new ones tho, To do this i need to be able to pass a function to the particle when its created then call that function when it dies. Is there a way to do this by passing function pointers?

View 9 Replies

Pass A Multidimensional Array To A Function?

Oct 29, 2010

I have a multidimensional array (not jagged array) that saves data from rows and columns of an excel spreadsheet. After it completes recording the data from Excel, I need to pass the array to another function.I understand how to pass a jagged array, but not a true multidimensional array.

Can someone point me in the right direction? I've done some searching on this site, and others, but most of the info only includes single dimension arrays or jagged arrays.

View 1 Replies

Pass An Integer Variable From The Sub To The Function

Dec 18, 2009

I don't think I fully understand passing values from a sub to a module. Here is what I'm trying to do (problem is at the '****):

[Code]...

I think I've seen something like this before - where the actual function returns a value. Is this possible? Or would I have to pass an integer variable from the sub to the function, and then return it back to the sub?

View 3 Replies

Pass Array To Function As Parameter?

Dec 7, 2010

I would like to pass array to function as parameter. Here is an example for variable that is not array:

[Code]...

View 5 Replies

Pass Array Variable From Vba To Function?

Mar 1, 2012

Im having a very difficult time trying to pass an vba array ive built from access vba to a .net function. I dont 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

<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
Public Class ComClass1
Public otag As String()

[code].....

View 1 Replies

Pass Control As A Parameter To A Function?

May 27, 2009

i am designing an application in which contents of an excel file are displayed in the ListBox. i have created a class which contains methods for doing this. Statement used for function call is:

oSheet = obj.displayColumns(oWB,
Me.lbColumnNames)

[Code].....

line where i am getting error is underlined. Is it possible to send controls as a parameter ?

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







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