List(of String) To Dim Item()() As String
Oct 22, 2011I have a list with a few items ( changes once in a while ) named itemlist
[Code]...
I have a list with a few items ( changes once in a while ) named itemlist
[Code]...
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]...
How do i set a label text to display any of the declared string list randomly.
CODE:
I am trying to get each item in a list box into a string array. However, I keep getting an index error and I am not sure why. I am doing this so i can perform a LINQ on the array.
Error:InvalidArgument=Value of '16' is not valid for 'index'.Parameter name: index
[code]...
Does anyone know how to do this? I'm stuck on a boat right now out to sea(Navy) and don't have access to vb.NET, its in my berthing...
So someone clarify this code and see if it works?
Dim index As Integer = list.FindIndex(Function(value As String)
Return value(0) = "STRING HERE"
End Function)
there's a list-box with items, and say you want to modify an item in the middle of the list. You select that item and click "Modify" button and a new form appears with the previously selected item data from first form ready to be modified in a text-box. After modifying and clicking Ok the second form suppose to return that modified string to the first form and insert the modified string into the same spot instead of the originally selected item, so it looks like it was edited to the user.
View 2 RepliesFunction runs fine on the listbox until i use the btnUp_Lanemgr click event
throws an exception in function (below in bold) "Unable to cast object of type system.string to type namespace.myitem"
what i can do to make this work?
'Button moves selected listbox item up
Private Sub btnUp_Lanemgr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUp_Lanemgr.Click
[Code]....
I'm having issues with finding something in list, and removing the item, ignoring the case of characters in string.
The code goes:
Dim listItems As New List(Of String)
Dim pattern As String = "AbC"
Dim array() As String
array = {"ABC", "abc"}
listItems.AddRange(array)
Here I'd like to remove all items from listItems, that are abc, no matter what case single characters of item are, including mixed case items. So in this example, every items should be removed
listItems.Remove(listItems.Find(Function(r) r = pattern))
If I change pattern to match the case of item, then item #2 gets removed:
pattern = "abc"
listItems.Remove(listItems.Find(Function(r) r = pattern))
How can I find item in listItems, ignoring the case characters in pattern?
I got an object of List<List<string>>I need to bring this into a ist<string>I have no idea how to do this with LINQ.
View 1 RepliesI have a List(of String()). I have written a custom comparer (implements IComparer(of string)) to do an alphanumeric sort.Is there a way to sort the List using a given index to determine which position in the String() to sort by? In other words one time I might sort by Index = 0 and another time by Index = 3. The length of all String() in the list is the same.For reference this question is similar to Sort List<String[]> except I am using VB.net and that question is hardwired to Index=0.
EDIT from OP's comments:I started simple with the non custom comparer but I am getting an error: expression does not produce a value. Not sure what I am doing wrong.Here is the code:
Public Shared Function SortListOfStringArray(ByVal ListOfStringArray As List(Of String()), ByVal SortByIndex As Integer) As List(Of String())
Return ListOfStringArray.Sort(Function(x, y) x(SortByIndex).CompareTo(y(SortByIndex)))
End Function
Whats the best way to convert a list(of string) to a string with the values seperated by ,
View 3 RepliesI've been trying to feed a multi line textbox into a string array then check item by item if a string contains part of it.
[Code]...
Dim namelist As List(Of String) = New List(Of String)
namelist.Add("Hi")
namelist.Add("Hello")
[code].....
I am trying to declare List(Of String(2)) and it doesn't work
I understood that if I specify the length of the string() the compiler will not need to guess the length and it will be more fast that way, is it correct?
I have two List(Of String) both containing several hundred thousand results.
Private Function AddUniqueFiles(lNewFiles as List(Of String)) As outList(Of String)
Dim aCounter As Integer = 0
Dim files As New inList(Of String)
[Code]....
However the time it takes to do this comparison can be very long indeed - is there a better way of doing this type of comparison... All I am trying to do is add values from List2 in to List1 which are not already present in List1 - So in effect adding new Unique values found in List 2 in to List 1. I am only looking for performance improvements - nothing else.
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]....
What would be the fasted method of get a string list of all values within [] in a string of text? For example: [client_name], are you are doing today? My name is [my_name]. The list of strings would be:
[Code]...
Can I do anything more or less with IDictionary? How do these two collections differ?
View 5 Repliesmy code is :
[Code]...
The error is Value of type '1-dimensional array of string' cannot be converted to 'String'.
We're working on a big ASP.NETVB.NET website project. I need to populate three dropdownlists. To last two are independent of the previous ones. The population data comes from an SQL Server. I'd have no problem doing this with code-behind with post back but we don't want any PostBacks so I started to develop this in AjaxjQuery.
[Code]...
I'm trying to solve a problem regarding types of list. First of all I have a stored procedure in my DB which does a select of a single column and I try to proceed it in my app in VB. By making a method function I declared a DataTable that loads through the SqlCommand(with the CloseConnection behavior). After that I publicly declared a List(Of String) which needs to be populated with the rows/items from the stored procedure that is on the way. Below is my snippet of the code:
Dim dt As New DataTable()
Try
If conn.State = ConnectionState.Open Then
[Code]....
It's LPrefix = collection.Cast(Of String)() where I get an exception error telling me that I can't really convert it. The old fashion way is to iterate with for/for each loop but that's not what I want for best use of performance especially if the list will have thousands of rows from a single column. So basically, I want to insert those items from that DataTable to the List(Of String) without For/For Each loop.
Running on VisualStudio2010 Ultimate, .NET FrameWork 4.0.
How do I assign a My.Settings.Item connection string to cmd.Connection connection string value?
Dim cmd As New SqlCommand()
cmd.Connection = My.Settings.Item("csStaffHoursWorked")
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "spSaveDeltekImport"
If a have for example Dim myList As String()and inside my program I want to add items to this variable how can I do this?
View 7 RepliesI'm writing an application to help manage an employee database. It displays the current entries in a ListView control using the SELECT FROM sql string and allows entry into the database using the INSERT INTO sql string. What I want to do is have the user select an item from the listview and be able to delete it from the database. How I'm trying to go about it is by detecting when the user presses 'Delete'. When they do, the program gets the string value of the item, hands it off to a variable, and the variable goes into a DELETE FROM sql string and deletes the row in the database.
I have multiselect disabled in the control so only 1 selection is possible at a time. I don't know how to detect the Delete key or how to get the string value of a listview item into a variable. If I know how to do these two things, I can work out the rest of the application. I'm still kinda new at this kind of stuff, so any responses will have to be dumbed down a little.
I have the following code:
[code]...
The intention is to convert an IList of custom objects to a string equivalent comprising each element in the Ilist. Unfortunately I can't seem to find a way to get the underlying data of the custom object, and of course as in the above example, using object simply gives me a string of types definitions, rather than access to the underlying data.
I have a list box on the form which functions as a copy/paste. When you copy something, it is automatically added to the list box as a "clipboard helper". Here is the problem,however: if the text is more than 1 line, the list box does not show all the text.It ends up looking messy.So getting back to my question, is it possible to make the list box item height for an item depending on the amount of lines that item contains?This is a one line sentence in the list box and should take up one line.This is a multi line sentence in the list box and should take up two lines for item height.
View 11 RepliesI have a List (Of String()). I wish to find the count of the 3 item in each string array in the list. Is there an easy way to find it using linq?
View 9 RepliesI am coding for a WPF application that has a ListView. I want to add values of one column of selected items in the listview to a string array.
View 2 RepliesI keep getting the error " Object reference not set to an instance of an object." in relation to the line : selA = CType(lstStudents.Items(r.Index), String)
[Code]...
I have a gridview with 2 columns.
First field contains checkbox named chkSelect and second column is a label which is binded with EmailId.
<asp:GridView ID="gvwNewsLetter" runat="server" AutoGenerateColumns="false" DataKeyNames="UserID">
<Columns>[code]......
When I check each checkbox I have to display mailid in corresponding row in a textarea which is outside gridview like" [url].... If I uncheck inbetween I have to remove that particular id from textbox.