Initialize List Of String?

Jul 6, 2010

Dim pix() As new List(Of String) = {"*.jpg", "*.avi", "*.mov"}
Dim pix As new List(Of String)() = {"*.jpg", "*.avi", "*.mov"}
Dim pix() As List(Of String) = {"*.jpg", "*.avi", "*.mov"}
Dim pix As List(Of String)() = {"*.jpg", "*.avi", "*.mov"}

Does it matter where the () are?

What difference does New make?

View 1 Replies


ADVERTISEMENT

How To Correctly Initialize A List Of Classes

Jun 27, 2011

I'm trying to create a group of engineers (a class) at a specific location (also a class) -- my code is bombing with a NullReferenceException at _engineers.Add(e), and I'm not sure why.[code]

View 3 Replies

Initialize Program String Array?

Jul 5, 2011

How create a array of objects (another class) in VB.NET and initialise it. Since I am not sure about the length of the array, it should be generic. I mean I should be able to add any number of objects to the array.

View 2 Replies

String.Empty To Initialize A Variable?

Mar 31, 2009

I always initialize my variables with a value when declaring them.I was wondering if using String.Empty to initialize a variable is correct.'Is this OK ?

Dim strValue As String = String.Empty
'I used to do
Dim strValue2 As String = ""
On the same subject.

[code]....

View 13 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

VS 2005 : Initialize String Array In Parameter?

Mar 9, 2010

how should i initialize the string array in this procedure call

vb
Private Sub SetAddres(Optional ByVal Addrvalues(4) As String ) End Sub

how to initialize it with values and also with empty strings or null values

View 7 Replies

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

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

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

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

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

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

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

Reorder A List Of String Into A New List?

Mar 29, 2012

I want to reorder a list of strings into a different list of strings. I am creating multiple loops to do this, however i was wondering if there was a better way to do this.

Dim values As New List(Of String)
For Each val As String In vals
If val.Contains("10") And val.Contains("Year 1") Then

[Code]....

There are going to be quite a lot of these loops to do what I want can anyone offer any help or a better way to go about doing this? Note that I want the values list to return 10,10,10,20,20,20 so that lines that have 10 should be added first and lines with 20 then afterwards.

View 2 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

.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

.net - How To Initialize A Singleton

Nov 6, 2009

Sometimes there is a need to initialize the singleton class with some helper values. But we can't "publish" a constructor for it. What is the workaround for this?overloading the GetInstance or setting a color is not my idea. The color should be set only once. I would like to be sure that MyPainter paints ONLY with the initialized color. Any default color should ever be used.

For more clarity I provide a sample:

''' <summary>
''' Singleton class MyPainter
''' </summary>
Public Class MyPainter

[code]....

View 5 Replies

How To Initialize A CBoolProperty

Aug 19, 2009

How can i initialize a CBoolProperty? [code]but when i debug. m_bHeight.Value is always true until i set bHeight with false. I want to initialize it to false.

View 5 Replies

Why Do Initialize Variables?

Nov 1, 2011

Take a look at this code

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

View 5 Replies

Add To A List(Of String) While Using One?

Jan 14, 2010

I'm thinking about making a queue system for my program which uses Asynchronous file downloading.

Now what I'd like to know is if I setup a For Loop like so[code]...

And I add to that list while the program is looping through this, will the program pick up that new Item, or do I need to find a way to abort and restart?

View 3 Replies

Getting A String From A List Box On One Form To A List Box On Another Form In VB 2008

Oct 17, 2010

I need to get a string from an items collection in a list box on one form to a list box on another form in VB 2008. Here is the code (I've tried a couple ways in the code to get the values over).

Public Class frmPrintBooks
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnClose.Click

[Code]....

View 3 Replies

.net - Initialize ArrayList WITH Elements?

Jan 27, 2011

I can create an ArrayList, but, is it possible to create it WITH some elements already?Normally, your arrays are empty, but what if I want to create an array with a few elements already?

View 2 Replies

.Net Application Failed To Initialize

Apr 10, 2006

.Net application failed to initialize

View 7 Replies

Asp.net - How To Initialize A Combobox In InitNewRow

Jun 29, 2011

I'm Trying to populate an ASPXComboBox using the InitNewRow event for inserting a new row, but I'm having problems binding the data to the ASPXComboBox.

I have used the CellEditorInitialize event for editing the row and it works fine, but the same principal on the InitNewRow event comes up with an 'object not set to an instance of an object' exception. However, the business logic function which is called returns a fully populated DataTable.

View 1 Replies

C# - Need To Initialize New Instance Of Object

Aug 11, 2011

The following code:
CodeVariableDeclarationStatement variableDeclaration = new CodeVariableDeclarationStatement(
// Type of the variable to declare.
typeof(string),
// Name of the variable to declare.
"TestString");

Produces the following VB.Net Statement:
Dim TestString As String

What change would I need to make for it to look like this:
Dim TestString As New StringBuilder()
I'm interested in how to get that NEW keyword to appear.

View 1 Replies

Classes And Arrays How To Initialize

Nov 1, 2011

working on some partial classes but I ct figure out how to do it.This is my classes:

Partial Public Class Form
Private InfoField() As Info
Private FormgroupField() As FormGroup

[code].....

View 1 Replies

Failed To Initialize COM Object

Aug 21, 2011

I have created a web application in ASP.NET using VB.NET as code behind file. I am using a COM object of ProvideX.Script class to connect to Sage MAS90 ERP. Everything was working fine in visual studio 2010. Now when I moved to the deployment phase, the problem gets started. I deployed my application in Windows Server 2008 in IIS7. When I run the application I get the following exception.[code]...

View 2 Replies







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