List.Find Parameters And Anonymous Delegates?
Aug 31, 2010Impossible in VB.NET 8(?) List.Find Parameters and Anonymous Delegates
View 3 RepliesImpossible in VB.NET 8(?) List.Find Parameters and Anonymous Delegates
View 3 RepliesI 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]...
Is it possible to create anonymous delegates in vb.net version 8 or earlier? If so, could someone provide an example of the syntax?
View 2 RepliesHowever, 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.
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]...
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]...
Ok i'm trying to declare a global list of type T (or is it <anonymous type>) i declare it in a module with something like Friend query As New List(of {whatever type i try}) the app takes some xml and parses it into a list but i need this list available to other classes and methods within the app, everything i have tried fails resulting in an error like Value of type 'System.Collections.Generic.List(Of <anonymous type>)' cannot be converted to 'System.Collections.Generic.List(Of {whatever type i try})'.
What would be the correct way to declare a list of this type? is there another way i could do this?
I'd like to create a list of an anonymous type, for example:
Dim dsResource = New With {.Name = dsResourcesEnd(index).Last_Name & ", " & dsResourcesEnd(index).First_Name _
, .StartDate = dsResourcesStart(index).Day _
, .EndDate = dsResourcesEnd(index).Day}
I have created that anonymous type. Now I'd like to add it to a list of that type. How do I declare a list of that type?
Any best approach to what I'm trying to achieve (linq to sql, returning list of data to show in a grid/list etc etc)... Its complaining about anonymous type conversion, and from what I'm reading, thats not elegant way of doing it.
Public Function GetHistory(ByVal historyId As Integer) As List(Of ?????????)
Using dc As New myDataContext(Application.GetConnection)
Return (From t In dc.ActionTypes, a In t.MyTable Where a.HistoryID = historyId Select a.ActionOn, a.ActionBy, t.Description, a.ImpactedItem, a.ActionDescription).ToList
End Using
End Function
What are Delegates and Multicast Delegates in VB.NET? How do I use them? provide a simple example to illustrate the concept.
View 1 RepliesGetting this error message and I am not able to figure out why. Here is my code:
<asp:TextBox ID="searchParam" Width="250px" runat="server"></asp:TextBox><asp:button ID="btnSearch" runat="server" Text="Search" />
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="getCOMDLs" TypeName="NewEmployee">
[Code]...
I am building a module that uses gridview and formview to display data in a grid, using VB as my backend, developing in VS2008. When I try to implement the module, I receive an error about matching parameters.From what I have read, this error kicks back due to a discrepancy between the VB and the SQL stored procedures.My query should be totally okay, but I don't know where exactly I should be looking in my visual basic...I have five separate VB files; the view.vb file, edit.vb, settings.vb, the controller.vb, and info.vb.I had thought that my best bet might be the controller file, but I can seem to find anything that might be missing.
Error report to follow:
Parameter count does not match Parameter Value count. ---> System.ArgumentException: Parameter count does not match Parameter Value count. at
[code].....
Is there any way to pass multiple values (a list of values) to a query via ODBC Parameters in VB.Net?
For instance, is there a way to create a query along the lines of:
-- vb.net has something like Dim itemNumbers As New List(Of Integer)(SomeCount)
SELECT Cost, Description
FROM MyItemList
WHERE ItemNum IN (<my list of item numbers>)
I'm a beginner in VB.NET programming.. Please help me on how to pass SQLParameters in the below function..
This my code:
[Code]...
The FxCop says in a rule that generic List should not be exposed to the outside world.But I do not understand why and what is the replacement for the generice List? url...
View 4 RepliesI'm a Linq noobie, maybe someone can point me in the right direction. What's wrong here? These anonymous types seem to have the same signatures.
[Code]...
For example, assume that in my assembly, in Namespace A, Class B, there is an instance method with the following signature: void Test(string someString, int someOtherParm, string someOtherString ); This method is called multiple times, from multiple places in the assembly. I would like to be able build a list of all invocations of this method and the value of the someString/someOtherString (assuming they are hardcoded). In other words, I like to extract a list of calls like the example one below, if they happen in the assembly somewhere: Test("some text", 8, "some other text");
View 1 RepliesGOAL: Bind nested ListViews to LINQ generated iQueryable of anonymous type. I want to use LINQ because you can use GroupBy and bind the nested ListView to the 'it' keyword.
SETUP: I have groups of sets of conditions. Each set of conditions is stored in the BillingCodes table. Each group of BillingCodes is stored in the BillingGroups table.
I have a custom object that stores the ID, Name, and NumCodes for each BillingGroup that the user has chosen.I have a collection of these objects called GroupsList that has a list of the groups that the user has chosen.
Problem 1: I can iterate through GroupsList and grab all the IDs. How do I translate the SQL 'WHERE ID IN(a string of comma delineated IDs)' for LINQ to SQL? Is that the best way to do that?
Problem 2: Once I have the list of BillingGroups I need to iterate through each group. For each group, I need to iterate through the BillingCodes. For each BillingCode I need to generate a WHERE clause that has all of the conditions in the BillingCode. I propose something like so:
for each BillingGroup in BillingGroups
for each BillingCode in BillingGroup.BillingCodes
where1 = "..."
next
next
Problem 3: Here's the part where I don't have a clue. I need to dynamically create a query in LINQ to SQL. Keep in mind that I don't know how many groups there'll be or how many codes are in each group.
There are 2 tables:
**transactions**
transaction_id
patient_id
[code]....
After reading all the examples for list of T exists and Find and find first, none show how to handle multi-property objects. Below is bare bones example maybe someone could flesh out to show how this should be done.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim DatePriceList As New List(Of DateAndPrice)
DatePriceList.Add(New DateAndPrice(Date.Parse("1/1/2000"), 10.12))
DatePriceList.Add(New DateAndPrice(Date.Parse("1/2/2000"), 11.12))
[Code]...
I have a list of specific class.In this list , a position class is included.And that position class includes X and Y coordinates.I have Current Coordinates and the coordinates in list .I want to calculate the distance for each item in List and find which item has minimal distance.Here is my code :
For Each item As ITEMX In xHandle.ItemList
Dim CurrX As Integer = txt_TrainX.Text
Dim CurrY As Integer = txt_TrainY.Text[code]....
so distance is the distance between my coordinates and the item.I calculate it for each item in list but how do i find the minimal one ?
I'm writing a query to select all records that has any part of parameter. I have one table called Employees. Some people have name like this: John David Clark If the parameter is
[Code]....
I should be able to get result back as long as there's a match in the parameters. If I use Function Contains (q.FirstName & " " & q.LastName).Contains(employeeName), I will not get any result back if employeeName is "John Clark" Function Contains looks only for next words from left to right. It doesn't match a single word at a time. So that's why I used this in the Linq to SQL:
[Code]....
i m getting a collection of data in list's object. And from this list i want to get the maximum id.`
Dim objinfo As List(Of AlbumInfo) = objPhotos.GetPhotos_Alb_ID(Me.ModuleId, hdd_AlbID.Value)
Dim Photo_Image As String = ""
Dim str As String = Photo_Image & fu_Photo.PostedFile.FileName.Substrng(fu_Photo.PostedFile.FileName.LastIndexOf("."))
[code]....
this returns the "0"th positions id from Convert.ToString(objinfo.Item("0").Photo_Id + 1)but i want to get the last item's id.
I have a simple class called Player. I can add players to it, but haven't figured out how to remove them. I've tried various ways, some compile some don't none work
Public Class Player
Public Name As String
Public Sub New(ByVal name As String)
[code].....
Does anyone know where I can find a list of symbols used in VB?I'm trying to place documentation in a program, but I want VB to ignore the line.
View 5 RepliesI have a list of names with corresponding numbers (In this case volume and weight names and their corresponding conversion number to deciliter and gram)
I have been looking how to program something like this in visual basic and came up with a list of class objects in which i could then do a find for the name and then get the corresponding modifier decimal.[code]...
I am writing a program using editable list boxes that will then be compared to a string later. I have no problem editing the listbox, but I am having trouble figuring out how to compare the list of things to the string. I envision using either a "for/next" loop or a "do/while" loop.
Mostly, what I need is the way to read the list box one entry at a time, in order.
I've been looking at the List(Of T).Find method and cannot figure out why it is useful?
Microsoft's example for using it is as follows:
CODE:
I am getting error [07002] the # binded parameters < the # of parameters makers, i checked both parameters were perfect even though i am getting this error here is my code
[Code]...
Where can I find a list of Virtual key codes? [code]
View 4 RepliesCan't find a drive list box in the tools (2010).
View 4 Replies