Changing The Value Of A Structure Member While Contained In A List(Of... )?
Apr 6, 2011
I have a question that I really hope someone can shed some light on for me, as this is driving me crazy trying to figure this out. Consider this code..
'declare and allocate
Dim lstNumbers As New List(Of Integer)
Dim nCount As Integer
In VB.NET, let's assume I have the following Structure:
Public Structure Product Public ItemNo As Int32 Public Description As String[code].....
How would I define a LINQ Query to Sum all of the Product.Cost values in the List? In other words, what would be the LINQ Query in VB.NET to return the value 120.90, which reflects the sum of all three Product Cost values in a single LINQ Query?
dim l as List(of MyClass) = new List(of MyClass) and I want to get the type of the objects contained in the list, how do I do that? The obvious answer, that doesn't seem to be possible from my actual implementation, would be to do something like this...
public function GetType(byval AList as IList(of GenericType)) as System.Type dim lResult as system.type = nothing if AList.Count > 0 then lResult = AList(0).GetType return lResult end function
But what if the list is empty and I still want to know the type it contains?
I have problems with array of structures.my structures are like this
structure order xxxxxxxxxxx yyyyyyyyyy zzzzzzzzzzz end structure
and then I created many array of structures, like this private arrayorder (100) as order
now i need to sort the entire xxxxxx member of the array of the structure with a function, but I dont want to use loops with arrays indexes to access the information. I want to know if there is another method to reference the array and the member of the structure to get the data.
I am using a structure array with multiple member names with 2 types. My question is can you single out one of the member names and add its total? kinda like this...
HTML Code: structure structureName dim a as string dim b as double dim c as double
I am trying to display a list of databases contained in sqlexpress, in a listview. my current code reads:
[Code]...
This will show up as column headers, but I can't get them to show in only one column so that I can have the user select the database that they would like to work with.
I have created a Class Library (dll) with a module and a class in it.The module declares a structure, and an instance of this structure.In the class, there is an arraylist declared.My main program calls a function in the class library class. The class calculates data, stores it in the instanceof structure. Then adds it to the arraylist.When i want to use this data in my main program, i get a Cast void error. Its because The structure of the data in the array if of the structure in Class Library module. Is there a way to change the structure of this array to an identicle structure in the main programs Module. When the function returns the arraylist I have tried storing it in a tmp arraylist and copying, cloning etc the data into another arraylist in my main program. still not working. Do i have to loop through all the data and copy each value to a new instanceofstructure, and store this in the new arraylist?
How do I change the program path '"logic.txt", "G:"' in the code below to theOpenFileDialog.FileName? Cos when I tried it, I receive String conversion errors and I tried altering the codes but it didn't work out well
vb.net Sub Button1Click(ByVal sender As Object, ByVal e As EventArgs) Dim sb As New StringBuilder(260)
am trying trying to write some code for a ComboBox that does the following:
1. Allow the user to enter text into the combo box to type entries contained in the list source.
2. Enable autocomplete to assist the user in selecting entries in the list source, both from dropped down state and non dropped down state.
3. Restrict the user from typing an entry that doesn't exist in the list source.
My requirements are:
1. The ComboBox must run some code after a selection has been made or the user has finished typing an entry (not after the focus has been moved to another control)
2. The code must only run once after the user has made a selection from the combobox or has finished typing an entry
The problem: To achieve the above functionality, I had to run code on numerous event's. Sureley there is a better way, here are the events and the reason for the code:
SelectedIndexChanged:This is the code that is run when the user makes a selection. No Mystery here
KeyDown:
Must Run If e.KeyCode = Keys.Return Then ComboBox1_SelectedIndexChanged(Nothing, Nothing) End If
If I have a list of list of myparams, can I access the sub structure of my params directly by indexing the list emelments?, eg..structure myparamsdim p1dim p2end structurepublic my_list as new list(of list(of myparams)))' now try to access list data directly by indexing..my_list(2)(3).param2 = 3but line above cuses error msg= Error 1 Expression is a value and therefore cannot be the target of an assignment!VB2005 starter
In the following code i get a warning at line 59:Warning 1: Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.and.. At line 78 I get this Warning:
Warning 2 Property 'SelectedCustomer' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used.
The program compiles and runs well, but i cant' undesrtand the reason for these warnings. Any Idea ?
1: Public Class Form1 2: 3: 'Form level members 4: Private objCustomers As New ArrayList
Cannot appear to be able to get this function to not have the above error.Private Function GetIncidentActions(ByVal FromAgentID As Integer, ByVal ToAgentID As Integer, ByVal incidentAction As Integer, ByVal ActionDate As Date) As String
Here I have a code to search a list if a word appears in a member information. What I want is to do a search if, in the phone numbers of members, one of them starts with 0 or 1 or 2 etc. ... How? I have this code to search on a word:
I have a combo box that is populated with a list of objects (corresponding to all employee rows from a database that meet the criteria IsTech). These are not entity objects though, I have created my own class that stores the member values of each row from the DB. I have set the DisplayMemberPath to EmployeeId so the Combo box display the EmployeeId ( an integer ) member of my object. Ie. right now there are only 2 IsTech employees in my DB so the combobox displays the numbers 3 and 8 ( their EmployeeIDs).
when I phase a specific column from a table using a combox then if I delete a data from the combox the respective record is deleted from the table.but the column value which I delete from the combox is still there.I want with the table the combox is also updated after delete record
In a list(of structure), i constantly have to modifiy the property of items using this code
Private Sub ChangeState(ByVal ww As WebWorker, _ ByVal NewState As WorkerState) Dim oWBB As WebWorker = ListWebWorkers.Find(Function(item As WebWorker) item.Browser.Name.ToLower = [code].....
But this give problem when two or more of the items call this sub procedure. in that one item may already have been removed. This code is executed in the ui thread, and has to be.so is there a better way to modify the items in list structure?
I have a user defined structure in a list that I am trying to change the value for in an individual element within the list of structures. Accessing the element is not a problem. However, the compiler complains
"Expression is a value and therefore cannot be the target of the assignment"when I try to update the value.For example:
Public Structure Person Dim first as String Dim last as String Dim age as Integer