2013-02-22 54 views
0

我有這兩個行代碼:.NET split命令代理奇怪

Dim templine() = Alfalines(i).Split(DataGridView1.Rows(s).Cells(1).Value) 
textlines(i) = Alfaline(0) + DataGridView1.Rows(s).Cells(language_row).Value + Alfaline(1) 

DataGridView1.Rows(s).Cells(1).Value從第一線具有在錯誤的時刻的值和"Form2A186_1"Alfalines(i)「標題=‘Form2A186_1’

的問題是,分割命令識別爲分隔符F和它將該字符串:

0: "Caption = "  
1: "orm2A186_1" 
+1

您對OPTION STRICT的設置是什麼?打開或關閉,我認爲關閉。 – Steve 2013-02-22 15:45:37

回答

1

我覺得這裏的問題是,String.Split()方法與參數只佔用的char []作爲參數,而不是字符串或字符串[],按照文件在這裏: http://msdn.microsoft.com/en-us/library/system.string.split.aspx

所以爲了按字符串分割,您應該使用此過載:

Public Function Split (_ 
    separator As String(), _ 
    options As StringSplitOptions _ 
) As String() 
+0

感謝您的回答,您能舉個例子嗎? – 2013-02-22 16:31:12

+0

MyString.Split(new String(){MySeparator},StringSplitOptions.None) – Hassan 2013-02-25 06:42:11

+0

此示例是否適合您? – Hassan 2013-02-26 16:43:09