.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


ADVERTISEMENT

C# - With LINQ, How To Transfer A List<List<string>> To List<string>

Dec 15, 2010

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 Replies

.net - Return A String Array From A Function Without Initialising It First?

Dec 10, 2009

Public Function Foo() as String() Dim bar As String = {"bar1","bar2","bar3"}

Return bar End Function

My situation is similar to the code sample above where I'm returning a string array from a function.

What I would like to do is just return the string array without having to declare a variable first and then return the variable.Something like this, although this obviously doesn't work:

Return {"bar1","bar2","bar3"}

Is it possible to do this, I can't seem to find a method that works?

View 2 Replies

Return List Of String That An Object A Has Username

Dec 2, 2010

How to return Ilist of strin that object a has username i want return that name

View 1 Replies

Return Rows That Have A Matching String To Predefined List?

Jul 8, 2009

1 within each section of a SplitContainer. The left hand side will be for inputing text that is copied/pasted from a word, excell, or text file.The right hand side would be for my output. What I would like it to do is return just the rows from the left hand side that contain a match to any one of the predifined strings. This will be used to search large lists of company names and circuit IDs and return the rows with matching namesSo far I have the form created, the Splitcontainer in place along with the richtextbox on each side and a submit button at the bottom.

View 12 Replies

Retun List Of String From A Function

Nov 27, 2010

i'm trying to return List(Of String) from data layer..When i run these code,it returns null value,but i use string instead of List(Of String),it return single value..

Data layer
Imports System
Imports System.Collections.Generic
Imports System.Text

[Code].....

View 4 Replies

VS 2008 List Of String Function?

Oct 8, 2011

I have added a module to the project. Inside the module I have the following

Public Function ListOFT() As List(Of String)
Return ListOFT
End Function

When I try to add something to ListOFT I get:

Quote:

Object reference not set to an instance of an object.

View 9 Replies

Sorting - Sort List(of String()) Using A Variable Index Into String() As Key ?

May 30, 2012

I 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

View 1 Replies

Get Each Item In A List Box Into A String Array?

Apr 15, 2012

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

View 1 Replies

Convert List Of String To A String Separated By A Delimiter

Apr 15, 2009

Whats the best way to convert a list(of string) to a string with the values seperated by ,

View 3 Replies

Convert A List(of Long) Into A String Array?

Oct 26, 2009

I want to convert a List (of Long) into a string array.

Reason: it's a list of database IDs and I want to make a comma delimited string to pass into a stored proc.I tried this:

Dim commaDelimitedList As String = String.Join(",", itemIDList.Cast(Of String)().ToArray)

but I'm clearly not using the Cast correctly since it throws an exception:

System.InvalidCastException: Unable to cast object of type 'System.Int64' to type 'System.String'..

Is there a way to get Cast working for this, or am I stuck with ConvertAll and a delegate function?

View 3 Replies

Converting A Generic List To String Array?

Mar 8, 2011

I have a generic List(Of Customer). The customer class has a name, address, and phone number properties. I also have a property of another class that accepts a customer name array. I am able to do this by doing the following:

Dim names As String()
Dim i As Integer = 0
'customer.GetCustomers is a List(of Customer)

[Code]....

Is there a better way to convert this to a string array?

View 1 Replies

Passing String Variables In Array List

Jun 12, 2009

I'm having difficulty passing a variables in a an array list. [Code] I have to pass the paramvals array to the function. The paramvals array contains the string but not the value of variable of that name. For example, parmaval(0) should contain the value of vSequence but it showing me that it contains string "vsequence".

View 3 Replies

Convert Array List To Comma Separated String?

Aug 28, 2009

I'm using String.Join to attempt to turn an array list into a string that is comma separated, such as "1,2,3,4". I can't seem to get the syntax working.

Here's what I'm trying:

Dim aryTest As New ArrayList()
aryTest.Add("1")
aryTest.Add("2")
aryTest.Add("3")

[CODE]...

How can I go about doing this properly?

View 3 Replies

Working With Generic List Of String Array Objects

Apr 7, 2010

I'm writing a program that reads a directory of xml files (not well-formed), parses the xml, and dumps the data into an Excel Workbook.The file contents are similar in that they have many common xml nodes/attributes.Some files have additional nodes/attributes.The xml in these files represent configuration settings for a Web Application, one file per user.The expected output is a worksheet with a column for each node/attribute combination and a row of node/attribute values for each user.I'm just about finished with the program, but I've run into a bit of a snag.As the final step in the process, I need to loop through a generic list of array objects (that represent a user row) and send the array elements to Excel.I don't know the correct syntax to get the array objects out of the list and have been unable to find sample code specific to generic lists of array objects.[code]

View 3 Replies

Gets A String (mysub(string)), But AddressOf Doesn't Accept A Parameter Inside The Routine?

Aug 18, 2011

I have buttons generated through code (dynamically). I have to associate an event (the same) to them. I use AddHandler button.click, AddressOf mysub.The issue is that mysub gets a string (mysub(string)), but AddressOf doesn't accept a parameter inside the routine. How can I do this? Using also an alternative to AddressOf.

EDIT:

Public Class Form1
...
Private Sub mysub(ByVal sender As Object, ByVal e As System.EventArgs, ByVal str As String)[code]......

View 2 Replies

Compare List(Of String) To Another List(Of String)

Dec 30, 2009

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.

View 7 Replies

String Split - Error Value Of Type '1-dimensional Array Of String' Cannot Be Converted To 'String'

Mar 11, 2010

my code is :

[Code]...

The error is Value of type '1-dimensional array of string' cannot be converted to 'String'.

View 2 Replies

Find Specific Characters (items) In String Array (or List) And Then Merge Them?

Mar 8, 2012

I'm having a problem recently, a logical issue so hard to determine various examples.I need the text that is inserted in textbox, which has been altered or modified or twisted to have a proper format through line accordance and constant white spaces etc. And some cases I stuck at defining the If statement within the loop. Here's an example of a text I'm trying to reformat.[code]I'm using Microsoft Visual Studio 2010 Ultimate version with Microsoft SQL Server Management Studio. This code is being fired on mouse click event of a button control. This is a snippet of my code there are more filtering after but here is what should be changed.

View 11 Replies

Play With List Of List Of String With Javascript Or Jquery Using Ajax?

Dec 5, 2011

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

View 1 Replies

Change This Checksum Function To Accept An Integer Input Instead Of A String?

Dec 31, 2009

This function doesn't work if I change the input argument 'pdu' from a string to an int.Would someone please help me figure out what to do here so that the checksum does not add the ascii value of the int argument but rather the actual integer value?I took out a few lines of the actual function but it adds the input argument to a packet sent out via TCP protocol.This function shows the integer value just fine in the string that gets encoded as a byte array. the checksum is wrong.!

''Public Function buildpacket(pdu As Integer) is what I want.
Public Function buildpacket(pdu As String)
Dim packet As String

[code]....

View 1 Replies

Convert A List(of String) To String()?

Nov 11, 2011

Dim namelist As List(Of String) = New List(Of String)
namelist.Add("Hi")
namelist.Add("Hello")

[code].....

View 4 Replies

How To Declare List(Of String()) With String(2)

May 5, 2012

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?

View 3 Replies

List(of String) To Dim Item()() As String

Oct 22, 2011

I have a list with a few items ( changes once in a while ) named itemlist

[Code]...

View 9 Replies

Cast/convert From List(Of DataRow) To List(Of String)?

May 22, 2012

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.

View 2 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 2008 Parse Text For Fields - Get A String List Of All Values Within [] In A String Of Text?

Oct 18, 2010

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

View 6 Replies

Vb.net - Convert From Custom List To List Of String

Mar 25, 2010

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.

View 2 Replies

Return A String From A Function

Jun 27, 2012

I have a class in this class i call a function which should return some string the class connects to an ftp server and list the directory and returns the filenames of the dir.

Code:

Public Function GetFileList(ByVal host As String, ByVal username As String, ByVal password As String, ByVal currentdirectory As String) As List(Of String)
Dim oFTP As FtpWebRequest = CType(FtpWebRequest.Create(host & currentdirectory),

[CODE]..........

So this should return all filenames of that directory

like:

Data1.xml

Data2.xml

Data3.xml

Now i have a form with a listview where i want to call this function and get the files of the "olist"

Code:

Return oList

HOW CAN I DO THAT? i mean how would my sub look like on my form where i want to call that function?

View 2 Replies

Return String From C++ Function?

Nov 8, 2011

I am trying to call C++ function from VB.Net code which returns string using PInvoke, but it is returning only single character.

C function Declaration
extern "C" __declspec(dllexport) LPSTR Get_GetDescription(HANDLE)
C function Defination
LPSTR Get_GetDescription(HANDLE resultBreakDown){

[Code].....

View 1 Replies







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