|
-
Mar 31st, 2006, 04:43 AM
#1
Thread Starter
Lively Member
[RESOLVED] Return an array of strings from itemarray
Somehow I'm not really getting how to correctly use .ItemArray()
I have a function that should return an array of strings.
The array should be populated by a) a datacolumn or b) a fixed set (in case no data in datatable)
VB Code:
Function SubExtensions() As Array
'Set the user defined Extentionlist
'When a custom list is saved it is loaded into table "Extenions" during startup (LoadSettings())
'If the list is empty populate with hardcoded list
Dim tbl As DataTable = frmMain.dsProgramSettings.Tables.Item("Extensions")
Dim row As DataRow
Dim item As String
Dim arrList() As String = {".mpg", ".avi", ".mov", ".wmv", ".iso", ".bin", ".nrg", ".mp4", ".img", ".bup"}
If tbl.Rows.Count > 0 Then
Return tbl.Rows.Item("Extension").ItemArray
Else 'Populate dataset table
For Each item In arrList ' fill datatable
row = tbl.NewRow
row("Extension") = item.ToString.ToLower
tbl.Rows.Add(row)
Next
Return arrList
End If
End Function
Itemarray returns an index of integers, but I want a list of strings (column "Extension"). How should I do that ?
Last edited by SammyWaslow; Apr 2nd, 2006 at 05:02 AM.
Using Visual Studio 2005 / Framework 2.0
-
Mar 31st, 2006, 09:12 AM
#2
Thread Starter
Lively Member
Re: Having troubles understanding/using ItemArray()
Using Visual Studio 2005 / Framework 2.0
-
Apr 1st, 2006, 07:24 AM
#3
Thread Starter
Lively Member
Re: Having troubles understanding/using ItemArray()
This line is giving me headaches
VB Code:
Return tbl.Rows.Item("Extension").ItemArray
Can anyone point me in the right direction on how to return an array (of strings) in this case ?
Using Visual Studio 2005 / Framework 2.0
-
Apr 2nd, 2006, 04:37 AM
#4
Thread Starter
Lively Member
Re: Having troubles understanding/using ItemArray()
Surely someone can help me out ? 
EDIT:
never mind. I realize I was looking at the wrong thing all along. itemarray returns and array of the columns in a row, whereas I want one column from all the rows. A loop it is then ...
Though strange i didn't get a reply on this one ...
Last edited by SammyWaslow; Apr 2nd, 2006 at 05:01 AM.
Using Visual Studio 2005 / Framework 2.0
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|