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
ADVERTISEMENT
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
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
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
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
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
Aug 1, 2011
After reading this post i realized that i cannot pass an anonymous type as a parameter to a function. So what other options do i have?
Perhaps, passing a Query.ToList as parameter would help, or am i re-inventing the wheel?
Update: I have the following query, which i would like to pass to a function:
Sub Test
Dim Query = (From c In DB Select New With { .ElementName = c.Name })
DoSomething(Query)
[Code].....
View 3 Replies
Oct 31, 2011
I have 2 functions, one is SaveData() and the other is SendEmail()
in the SaveData() the radio buttons that are selected are saved, and the SendMail() is called at the end.
in the SendMail() the radio buttons are "tested" and then one of two emails is sent out based on the radio choices.
The problem I am having is passing the parameters correctly. I have tried several different method but the parameters are not being sent to SendMail()[code]...
View 1 Replies
Mar 23, 2010
Basically, I have a gridview that is opened in a new window from the parent window. It has a bunch of records with a view button to view the details of each record (which stays in the same newly opened window). I have a calendar in the parent window that accepts a Date querystring parameter to set the current date on the calendar at page load. I'm just trying to refresh the calendar in the parent window to match the date of the label in the newly opened window.
All the code below is in the newly opened window. The .Net code-behind below refers to when that view button is clicked and everything is populated. At the end, I call the js to refresh the parent window and pass the value of the LabelScheduleDate as the querystring parameter. Now the label comes through as '03/25/2010' in the code-behind, but when I pass it to the js, it comes through as '0.00005970149253731343' in the end querystring. I'm not really sure what is making the value change, and I want to pass it as just text. Do I need to pass it as a string object? I tried but I don't think I was doing it right.
JavaScript Function
function RefreshParent(inputDate) {
window.opener.location = window.opener.location + "?Date=" + inputDate;
}
[Code]....
View 1 Replies
May 25, 2010
I have a query that can be summarised in SQL as follows;
Select
S.StockCode
From
StockToCheck As S
[Code]....
Where the S var is a list of strings. This gives the error 'S' is not declared and points to the S in the function call / join (GetPOSStock). So it does not seem possible to do this in Linq, can anyone confirm?
View 1 Replies
Jun 5, 2010
I have a sqlite table with following fields:
Langauge level hours
German 2 50
French 3 40
English 1 60
[code]....
I want to loop through the records based on language and other conditions and then pass the current selected record to a different function.So I have the following mixture of actual code and psudo code. I need help with converting the psudo code to actual code, please. I am finding it difficult to do so.
Here is what I have:
Private sub mainp()
Dim oslcConnection As New SQLite.SQLiteConnection
Dim oslcCommand As SQLite.SQLiteCommand
Dim langs() As String = {"German", "French", "English"}
[code]....
View 3 Replies
Dec 13, 2011
I need to execute a stored function in oracle or sql through vb.net. I created a command object. Depending on the database type(oracle or SQL) i am preparing the Command text as Select functionName(?,?,?,?,?,?,?,?) from dual; (For Oracle) Adding the parameter values of the function. Now performing the ExecuteScalar which is not working saying invalid parameter. This works with ODBC connection string. But ODBC doesn't with 64bit. My Requirement: Code should execute a user defined stored procedure by taking the values at runtime.
View 1 Replies
Jul 17, 2010
In VB6 I used some pattern of programming..I passed the picturebox as parameter to some procedure in some class and inside this procedure paint all needed graphics using this class methods.Now I want upgrade my application to vb.netBut all samples for line drawing show me how to draw inside paint event.[code]
View 2 Replies
Mar 22, 2012
I want to pass an optional parameter to a function of type System.Drawing.Color. The problem I am having is that when I declare the function it says "Constant expression is required" but I have tried variations of the following, including integers, full qualified indentifiers, even old vbWhite constants to no avail.
[Code]...
View 14 Replies
Mar 9, 2011
I want to have a "template" function that can receive different parameter and a type parameter, like:[code]But Vb told me that tupeList is not defined... is there a way I can do that?
View 2 Replies
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
Apr 1, 2010
I'm trying to undersatnd the syntax of calling a funciton and it seem confusing when I'm using a web service in ASP.net. Maybe this question should be in an ASP forum, but it is a VB question. This simple web service allows you to type in your name and it response with an alert box with you name.
My question is, How can you call a function with 2 arguments when the function is only defined for one. I understand that the second argument is actually a method that handling the respons, but how can you interchange function arguments for methods and how do you know that there are methods for
Here's my call:
<script type="text/javascript">
function HelloWorld()
{
var yourName = $get('txtYourName').value;
[CODE]...
View 7 Replies
Dec 14, 2009
The following two statements seem the same to me but the first throws a design time error, and the second does not. The first one is passing the first parameter in hex and the second passes the first parameter as its decimal equivalent.
Public Shared ReadOnly Test As New Guid(&HCC58E280, &H8AA1, &H11D1, &HB3, &HF1, &H0, &HAA, &H0, &H37, &H61, &HC5)
Public Shared ReadOnly Test2 As New Guid(3428377216, &H8AA1, &H11D1, &HB3, &HF1, &H0, &HAA, &H0, &H37, &H61, &HC5)
Here is the error associated with the first statement:
Error 1 Overload resolution failed because no accessible 'New' can be called with these arguments: 'Public Sub New(a As Integer, b As Short, c As Short, d As Byte, e As Byte, f As Byte, g As Byte, h As Byte, i As Byte, j As Byte, k As Byte)': Constant expression not representable in type 'Short'. 'Public Sub New(a As UInteger, b As UShort, c As UShort, d As Byte, e As Byte, f As Byte, g As Byte, h As Byte, i As Byte, j As Byte, k As Byte)': Constant expression not representable in type 'UInteger'.
View 1 Replies
Dec 9, 2010
its just like that in other langauges (php in the example)
function myFunction($message,$sender="nodoby") {
return $message." by ".$sender;
}
View 2 Replies
Nov 20, 2009
I want to pass the entire array to the next function[code]...
View 3 Replies
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
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
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
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
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
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
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
Feb 6, 2012
I have a Sub with an array of strings as parameter:
Private Sub des(ByVal array() As String)
Dim i As Integer
For i = 0 To UBound(array)
[code]....
When I call the function inside my main function , the value of str changes even if the array is passed to the function Byval
Dim str() As String
str = {"11111", "22222", "33333", "44444", "5555", "66666"}
des(str)
I tried making a copy of the array in the Sub, but it still changes in the main function
Private Sub des(ByVal array() As String)
Dim i As Integer
Dim array2() As String
[code]....
I read on a site that you cannot pass arrays ByVal ,is this true? If so , how should I proceed?
View 3 Replies
Mar 14, 2012
How can i create a optional parameter in C# as we create in VB.Net
Public Sub Demo(ByVal a As Integer,Optional ByVal b as integer=3)
End Sub
I want to declare this in C#
[code].....
View 2 Replies
Mar 3, 2011
I am using visual basic and trying to create function. I am getting this error:
"Argument not specified for parameter '_IsDayRateCheckBox' of private function CalculateParikingCharges(_HoursDecimal As Decimal, _IsDayRateCheckBox As System.Windows.Forms.CheckBox) As Decimal'.
This is the code.
Private Function CalculateParkingCharges(ByVal _HoursDecimal As Decimal, ByVal _IsDayRateCheckBox As CheckBox) As Decimal
This is how I call the function.
Dim HoursDecimal As Decimal
Dim AmountOwedDecimal As Decimal
If Not Decimal.TryParse(HoursTextBox.Text, HoursDecimal) OrElse HoursDecimal < 0D Then
ErrorLabel.Visible = True
HoursTextBox.Focus()
[Code] .....
View 3 Replies