vb.net使用逗号分隔的值从INI文件填充Combobox

时间:2012-03-27 15:27:54

标签: vb.net combobox ini

我正在尝试将逗号分隔的值添加到组合框中。问题是我不知道这是否是将值拆分为组合框的最佳方法。有更清洁/有效的方法吗?:

Dim toread As String
    toread = ini.ReadValue("Schools", "Schools")
    Dim textdelimiter As String
    textdelimiter = ","
    Dim splitout = Split(toread, textdelimiter)
    Dim i As Integer
    For i = 0 To UBound(splitout)
        ComboBox1.Items.Add(splitout(i))
    Next

1 个答案:

答案 0 :(得分:4)

你可以试试这个:

ComboBox1.Items.AddRange(ini.ReadValue("Schools", "Schools").Split(",").ToArray)