Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to convert string to List(Of String)?

Code:
VB
Dim name As List(Of String) = DB.GetNames(firstname).ToString() ?


It is giving me error when i try tolist(of string)

Can you help me with this?
Posted
Updated 10-Aug-15 9:50am
v3
Comments
hypermellow 10-Aug-15 11:36am    
Hi, you're getting an error as you are trying to assign a string value to a "List Of String" Variable.

What type does DB.GetNames return?
apr1234 10-Aug-15 11:37am    
Db.GetNames returns string but I want it to be converted to list(of string)
hypermellow 10-Aug-15 11:39am    
Ok, then you can add it's value to a List of String by name.Add(DB.GetNames(firstname))
apr1234 10-Aug-15 11:43am    
Thanks.. It worked
Actually I am new.. Appreciate your efforts!

Try:
VB
Dim name As New List(Of String)
name.Add(DB.GetNames(firstname))
 
Share this answer
 
Comments
hypermellow 10-Aug-15 11:52am    
I thought I'd been beaten to posting the same solution, but I notice you have specified the New keyword when declaring.

... my VB must be rusty(ier) that I thought :-)
Hi,

Here is a couple of ways.

1) - Declaring your list ... and then populating:
VB
Dim name As List(Of String) = New List(Of String)
name.Add(test())


2) Populating when declaring:
VB
Dim name As List(Of String) = New List(Of String)({DB.GetNames(firstname)()})


... hope it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900