Agis Markouizos
Agis Markouizos

Reputation: 47

.net split command acting strange

I have these two code lines :

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 from the first line has the value "Form2A186_1" and Alfalines(i) at the moment of the error :" Caption = "Form2A186_1"

The problem is that split command recognize as delimeter the F and it splits the String to:

0: "Caption    =   "    
1: "orm2A186_1"

Upvotes: 0

Views: 110

Answers (1)

Hassan
Hassan

Reputation: 2643

I think the problem here is that String.Split() method with on argument only takes char[] as its parameter, not string, or string[], as per documentation here: http://msdn.microsoft.com/en-us/library/system.string.split.aspx

So in order to split by string, you should use this overload:

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

Upvotes: 1

Related Questions