Populating a List with strings.
Populating a List with strings.
Populating a List with strings.
Populating a List with strings.
Populating a List with strings.
Populating a List with strings. Populating a List with strings. Populating a List with strings. Populating a List with strings. Populating a List with strings. Populating a List with strings. Populating a List with strings. Populating a List with strings.
Populating a List with strings. Populating a List with strings.
Populating a List with strings.
Go Back  Xtreme Visual Basic Talk > > > Populating a List with strings.


Reply
 
Thread Tools Display Modes
  #1  
Old 04-08-2015, 01:34 PM
hanoch_hendel hanoch_hendel is offline
Newcomer
 
Join Date: Jun 2005
Posts: 6
Default Populating a List with strings.


Code:
Dim Code_List As New List(Of String)
Dim Code as String

For i = 1 To How_Many_DG_Cargos
                'load List with 1 of each Code
                If Not Code_List.Contains(Code) Then
                    Code_List.Add(Code & vbTab)
                End If
Next i
The List is populated with one Code only (the last one) instead of all the Codes. Probably because of the “.Add”. How to cause the list to be populated with all Codes?
Reply With Quote
  #2  
Old 04-08-2015, 04:51 PM
PlausiblyDamp's Avatar
PlausiblyDampPopulating a List with strings. PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

From the code you have posted it isn't clear where you are assigning a value to Code, that might be the problem....
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 04-08-2015, 11:27 PM
hanoch_hendel hanoch_hendel is offline
Newcomer
 
Join Date: Jun 2005
Posts: 6
Default

Quote:
Originally Posted by PlausiblyDamp View Post
From the code you have posted it isn't clear where you are assigning a value to Code, that might be the problem....
Thanks.
Code is assigned a value in a different loop.
The problem I encounter is populating the List with all values, not only the last value.
Reply With Quote
  #4  
Old 04-09-2015, 02:49 AM
PlausiblyDamp's Avatar
PlausiblyDampPopulating a List with strings. PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

Could you show the code that is setting the value of Code? It sounds like you are looping through some values and repeatedly overwriting the value until the loop exits - at which point Code will only contain the last item.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Populating a List with strings.
Populating a List with strings.
Populating a List with strings. Populating a List with strings.
Populating a List with strings.
Populating a List with strings.
Populating a List with strings. Populating a List with strings. Populating a List with strings. Populating a List with strings. Populating a List with strings. Populating a List with strings. Populating a List with strings.
Populating a List with strings.
Populating a List with strings.
 
Populating a List with strings.
Populating a List with strings.
 
-->