Return All Keys With A Certain Value From A List Of KeyValuePair?

Oct 27, 2009

Given the following vb.net class:

Friend Class PairCollection(Of TKey, TValue)
Inherits List(Of KeyValuePair(Of TKey, TValue))
Public Overloads Sub Add(ByVal key As TKey, ByVal value As TValue)
Me.Add(New KeyValuePair(Of TKey, TValue)(key, value))
End Sub

[Code]...

View 1 Replies


ADVERTISEMENT

.net - Check Keyvaluepair Againt Existing Values In List Of Keyvaluepair

Aug 22, 2010

How can I check a new KeyValuePair against an existing list of KeyValuePair ? I want to compare for a condition to include or exclude the item. I am using vb.net 3.5

it is a nested For loop and I am deleting a datarow on the result of the condition

args = (existing list of KeyValuePAir)
For Each datarow As DataRow In ds.Tables(0).Rows
Dim args2 As KeyValuePair(Of Integer, Integer) = New KeyValuePair(Of Integer, Integer)(datarow.Item("Integer1"), datarow.Item("Integer2"))

what I want to do here is see if args2 is already contained in args if not I would delete the datarow , but I also need to search the datarow multiple times

View 2 Replies

WebForms :: Binding A List Of Keyvaluepair To ListView?

Sep 20, 2011

I am trying to bind a New List(Of KeyValuePair(Of String, Integer)) to a listView
Currently, I have a code off:

Dim TestList As List(Of KeyValuePair(Of String, Integer))
For Each key in GetTPDesc (Which is a list of strings)
TestList.Add(New KeyValuePair(Of String, Integer)(GetTPDesc.ToString, 0))

[code].....

View 2 Replies

Loop Through A List Of The Keys That Are Available In The 'Keys' Enumeration?

Jan 13, 2011

How could I loop through a list of the keys that are available in the 'Keys' enumeration? It seems like it should be something easy to do, but I'm not having any luck finding a collection that I can loop through.

View 6 Replies

.net - Convert A List (Of KeyValuePair(Of String,Int32) Into A Dictionary(Of String, Int32) Using .ToDictionary?

Nov 2, 2010

To be able to sort a dictionary by value I'm using this code:

Dim idCurrentJobs As IDictionary(Of String, Int32) = New Dictionary(Of String, Int32)
'The string in the dictionary represents a jobname and the integer is a counter for how many jobs im currently are running in the application'
idCurrentJobs.Add("JobName1", 2)

[code]....

View 2 Replies

VS 2010 Return Items In A List Before Returning The List?

May 23, 2012

That was probably bad title, but I'll illustrate what I'm trying to do. I have a method in a class that I need to call several times. The method returns a List(Of String). I'm just grabbing some information from a database.

VB.NET
Public Function GetTestList() As List(Of String)
Dim int As Integer = 0

[code]....

View 4 Replies

Get List Of ALL Registry Sub Keys?

Mar 8, 2012

I want to get all sub keys in a reg location. This entry can also have additional sub keys.At location "HKEY_CLASSES_ROOTexefile" this key as 3 subkeys and 2 of these keys have additional sub keys under them. I need to get all the keys and any additional sub keys under each key if there is any. This code will be used for other keys, so I can not assume they have subkeys.

Dim Key As RegistryKey = Registry.ClassesRoot.OpenSubKey("exefile", False)
Dim SubKeyNames() As String = Key.GetSubKeyNames()
Dim Index As Integer

[code]....

View 2 Replies

Alternative To RegOpenKeyEx To Get List Of Registry Keys

Jun 23, 2009

I need to get a list of registry keys. I have a key in HKEY_LOCAL_MACHINESOFTWARECBV

In there I have a couple of more keys that I need to list. After that I'll be able to get the subkeys easily.

I've looked and the only call that seems to do this is RegOpenKeyEx. Is there a better or more up to date method that I can use?

I've looked at My.Computer.Registry.LocalMachine and can only see methods to get the subkeys and not keys.

View 2 Replies

Sorting Generic List On Multiple Keys?

Nov 2, 2009

I need to sort a list (of person) to person.Age within person.Department. f I user personlist.sort with a comparer for Age and then sort again with a comparer for Department, the sequence of age is destroyed.

View 1 Replies

Game Programming :: Detecting Whether One Of The Arrow Keys Is Pressed, All The Other Keys Seem To Be Detected Apart From The Arrow Keys?

Oct 21, 2008

I have a problem detecting whether one of the arrow keys is pressed, all the other keys seem to be detected apart from the arrow keys??? I have set key preview to True........ It detects the arrrow keys BUT ONLY if I have NO other controls on the form??? example..

Me.Text = e.keycode

It works, but then if I add a button for example, it stops.

View 3 Replies

Extract A Keyvaluepair Out Of A Sortedlist?

Aug 6, 2011

i can get a value, a key out of a list by using index ,key or value parameters but a kvp as object ?nattelip

View 13 Replies

How To Use A Custom Structure In Place Of KeyValuePair

May 23, 2011

Is it possible to use a custom structure in place of a KeyValuePair? [code]

View 3 Replies

Sort Data In A Sorted List Using Values Instead Of Keys From Highest To Lowest?

Jun 15, 2010

How can I sort data in a sorted list using values instead of keys from highest to lowest?[code]...

View 2 Replies

List Of T Find Date Or Other Property In A Object In The List - Then Return Found Object?

Sep 3, 2009

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

View 3 Replies

Generics - Using KeyValuePair For A Reverse Lookup Capable Dictionary

Oct 26, 2009

I'm currently on a VB.NET project and wish to use a KeyValuePair to facilitate a reverse lookup. I've found a great example in C# here: [URL], however I am having a small problem converting to VB.NET (both manually and using a translator (online carlosag)). For example the syntax I would expect in the Add method is as follows:

[Code]....

View 3 Replies

Return A List Of Type T?

Jun 22, 2010

I would like to have a function(of T) that returns a list(of T) that is assignable to a variable of list(of T).For Example:

the variable:
Private _StandardCodes As List(Of StandardCode)
the assignment:[code]....

I'm getting the error "Type paramater 'T' for ... cannot be inferred", as a result I have to use a comparable function to return a list(of Object) and then do:

_StandardCodes = (From x In AMExtensions.queryObject(GetType(StandardCode), "StandardCode") _
Select CType(x, StandardCode)).ToList

View 5 Replies

Return The Array List?

Feb 6, 2009

I am having a little trouble trying to use an array list. I am using a function that I want to return the array list. However, I am having a problem getting it to return the arraylist. when i do this:

[Code].....

View 5 Replies

.net - Function To Accept List(Of String), Array & String And Similarly Return List(Of String)?

Jul 29, 2011

I want the Function to accept List(Of String), Array & String and similarly return List(Of String), Array & String respectively. The Function simply adds a string (month) to the input collection. I just want to use it for string, array and list with needing to think of conversions.

[Code]...

View 2 Replies

Filter A Dictionary To Return A List?

Apr 23, 2012

I know I can do this with a for loop cause that's how i'm doing it now. I was hoping for a more efficient way to accomplish the task.

I have a dictionary(Of Integer, Boolean) or Of String, Boolean. i want to get a list(of integer) or Of String from the dictionary where all the values are true(or false depending on what i need at the time)

and to generalize it or "black box" it, it could be any dictionary(of whatever, whatever) and return a list(of whatever) where the value = whatever i'm looking for at the time.

string, string where value = "Closed"

in short: i want all list of all the keys who's value = some criteria

my current code:

Public Function FindInDict(Of tx, ty)(thedict As Dictionary(Of tx, ty), criteria As ty) As List(Of tx)
Dim tmpList As New List(Of tx)

[Code].....

View 2 Replies

Return A List From A Compiled Query?

May 8, 2009

I was speeding up my app by using compiled queries for queries which were getting hit over and over.I tried to implement it like this:

Function Select(ByVal fk_id As Integer) As List(SomeEntity)
Using db As New DataContext()
db.ObjectTrackingEnabled = False

[code].....

View 1 Replies

Return List After Sorting With Repeater?

Jan 5, 2012

I have a list going into a repeater, sorting with jquery sortable(), and then need to put the sorted list into a session variable. I cannot seem to figure out how to get the sorted values back into a list.[code]...

View 1 Replies

Return Text Of An Item From A List Box?

Aug 8, 2010

I wish to get the Text of item where I know its index! most of the codes I have founds Return the index number not the text it self!

View 5 Replies

Use A Function To Return A List Of Strings?

Oct 5, 2011

Update: I didn't make it clear but I meant this to be a question about where/how I would use a function to return a list of strings when I'm trying to just work with classes.I have a class called Account.

I have data access class called AccountDAO.I have various functions that return lists of objects like GetAllAccounts, GetAccountByID etc.I want to populate a drop down list with just the account names and nothing else. It's proving rather slow when using lists of objects and databinding them to the dropdownlist.

I feel like I should be using a simple "Select Account_Name From blah" type statement and returning a list of strings but I don't know how to work this into my class and data access class.

View 4 Replies

Why Can't Return A List From A Compiled Query

Mar 9, 2010

I was speeding up my app by using compiled queries for queries which were getting hit over and over.

I tried to implement it like this:

Function Select(ByVal fk_id As Integer) As List(SomeEntity)
Using db As New DataContext()
db.ObjectTrackingEnabled = False

[Code].....

View 1 Replies

List.Contains Returns False, Even Though It Seems It Should Return True?

Feb 17, 2010

Sub pageload() Handles Me.Load
Dim bom As New List(Of Car)
Dim car1 As New Car With {.Name = "Pea", .Year = 2}[cod

WHY??? I mean the object has the exactly same data, so why does itee]..... say it is not contained?

View 3 Replies

Function To Return A List For A Dropdownlist Or Combobox?

Aug 27, 2009

I have written a function before to delete and update records, but never anything to return values back to my call of the function. Here is my code, and I will try to explain what I'm trying to acheive.

If Not Att1 = "" Then
Attribute1.Text = Att1
Attribute1.Visible = True
ComboBox1.Visible = True

[code]....

That codes goes on up to att20. It works just fine, but it is forever long, and I would like to clean it up.I want to do something like:

Or, should I pass the combobox number also, so that the code can fill the appropriate combobox? Like.comboboxfill(Att1,Combobox1) how to write the function and how to pass back the information or just how to make it work in general?

View 6 Replies

Group List And Return Only Cheapest One For Each Provider

Feb 2, 2012

I have an object called offer and it has sub object price as decimal and provider_ID as integer. What I need is I have list (of offer) and I need to get cheapest price for each provider. So lets says I have following:

Provide_ID Price
----------------------
1 30
2 40
1 15
2 20
3 5
3 10

How can I make a linq query (from item in offers group by item.provider_id into
max(item.price)) like this.
Because using group by I am not able to get all information of offer object. beside provider_ID and price I have more information. That's why I don't want to have (with {item.price, item.provider_ID}) etc. selecting each one by one.

And results of filtering should have only
provide_ID Price
----------------------
1 15
2 20
3 5

View 5 Replies

How To Read Two XML Files And Return List (of Objects)

Jun 20, 2011

I have two xml files. I have to read them and return as a List( Of object). Here is my function.
Public Function GetData(ByVal name As String, ByVal city As String) As List(Of Object)
'Return Nothing
End Function

View 1 Replies

Linq Return Results Contaiined In A List?

Mar 23, 2011

How can i select using linq from a datatable where the the only results I want back (ID's) are contained in a list of integers?

View 7 Replies

Return Folder List And Their Respective Sizes?

Jul 8, 2010

I'm trying to create a simple script that will return a list of folders in the current directory and their respective sizes:

Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set strCurrentDirectory = objFSO.GetParentFolderName(Wscript.ScriptFullName)
Set objFolder = objFSO.GetFolder("strCurrentDirectory")

[Code]...

Yet it doesn't like the fact that I am trying to pass the current directory into a variable and errors out with:D:dirsize.vbs(3, 1) Erreur d'exécution Microsoft VBScript: Objet requis: '[string: "D:"]'.

View 6 Replies







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