2011-08-17 106 views
0

我正在從Active Directory(名稱,部門,標題,公司,郵件)將數據檢索到用逗號分隔的字符串中,並且我想拆分字符串並將它們存儲到可以導出的數組它在Excel中更新到我的數據庫之前。在數組中拆分和存儲字符串

但我如何將它們存儲到數組?

下面的代碼:

我收到來自AD數據並將其存儲在列表:

Dim formattedName As String = String.Format("{0},{1},{2},{3},{4},{5}", _ 
            resEnt.Properties("name")(0).ToString(), _ 
            resEnt.Properties("company")(0).ToString(), _ 
            resEnt.Properties("department")(0).ToString(), _ 
            resEnt.Properties("title")(0).ToString(), _ 
            resEnt.Properties("sAMAccountName")(0).ToString(), _ 
            resEnt.Properties("Mail")(0).ToString()) 

       userList.Add(formattedName) 

上述循環完成後,我打印出來。但現在我想分割它,所有的數據存儲到數組

For i = 0 To userList.Count - 1 
      Response.Write("<BR>" & userList(i).ToString()) 
     Next 

我如何拆分,並將其儲存?

回答

1

嘗試

Dim strArr() As String 
strArr = userList(i).ToString().Split(",")