File io 用vb.net比较数据集

File io 用vb.net比较数据集,file-io,dataset,vb.net-2010,File Io,Dataset,Vb.net 2010,数据集(ds)包含这样的值:复制两个数据集,并将数据集中的电话号码写入记事本,这不等于数据集1。但我在记事本中得到的结果与两个数据集中的电话号码相同 dataset ------- 91 9942321400 91 9865015695 91 9677031515 91 9994828285 91 9688104229 dataset1 values ---------------- 91 9942321400 91 9865015695 91 9677031515 expe

数据集(ds)包含这样的值:复制两个数据集,并将数据集中的电话号码写入记事本,这不等于数据集1。但我在记事本中得到的结果与两个数据集中的电话号码相同

dataset
-------
91  9942321400
91  9865015695
91  9677031515
91  9994828285
91  9688104229

dataset1 values
----------------
91  9942321400
91  9865015695
91  9677031515

expected result in notepad
--------------------------
91  9994828285
91  9688104229

my code
-------
Dim i As Integer = 0
        Dim toggle As Boolean = False
        Do While (i <= ds1.Tables(0).Rows.Count - 1)
            Dim phone As String = ds1.Tables(0).Rows(i).Item(1).ToString
            Dim j As Integer = 0
            Do While (j <= Ds.Tables(0).Rows.Count - 1)
                Dim dumphone As String = Ds.Tables(0).Rows(j).Item(4).ToString
                If dumphone <> phone Then toggle = True 'This will set your flag to add the output.
                j = (j + 1)
            Loop
            'After we're done checking if there's a match, we decided to add it to the output.
            If toggle = True Then

                TextBox1.AppendText(a.ToString & "|" & b.ToString & "|" & c.ToString & "|" & d.ToString & "|" & phone.ToString & "|" & e1.ToString & "|" & f.ToString & "|" & g.ToString & "|" & h.ToString & "|" & i1.ToString & "|" & j1.ToString & "|" & k.ToString & "|" & l.ToString & "|" & m.ToString & "|" & n1.ToString & "|" & o.ToString & "|" & p.ToString & "|" & q.ToString & "|" & r.ToString & "|" & s.ToString & "|" & t.ToString & "|" & u.ToString & "|" & v.ToString & "|" & w.ToString & "|" & x.ToString)
                sw.WriteLine(TextBox1.Text)
                TextBox1.Text = ""
                toggle = False 'Reset the flag for the next value
            End If
            i = (i + 1) 'Move to the next value to check against.
        Loop



but am getting the output in note pad like this
------------------------------------------------
91  9942321400
91  9865015695
91  9677031515
数据集
-------
91  9942321400
91  9865015695
91  9677031515
91  9994828285
91  9688104229
数据集1值
----------------
91  9942321400
91  9865015695
91  9677031515
记事本中的预期结果
--------------------------
91  9994828285
91  9688104229
我的代码
-------
尺寸i为整数=0
变暗切换为布尔值=False

(我试过这种方法,我得到了你想要的结果

For i As Integer = 0 To dataset.Tables(0).Rows.Count - 1
            Dim found As Boolean = False
            For j As Integer = 0 To dataset1.Tables(0).Rows.Count - 1
                If dataset.Tables(0).Rows(i)(0).ToString = dataset1.Tables(0).Rows(j)    (0).ToString Then
                    found = True
                End If
            Next
            If found = False Then
                'here you are getting the right result in each loop
                'in this example i'm showing the result in a textbox
                'just change the instruction and write them in your note pad or wherever you want to
                MsgBox(dataset.Tables(0).Rows(i)(0).ToString)
            End If
        Next

我试过这种方法,我得到了你想要的结果

For i As Integer = 0 To dataset.Tables(0).Rows.Count - 1
            Dim found As Boolean = False
            For j As Integer = 0 To dataset1.Tables(0).Rows.Count - 1
                If dataset.Tables(0).Rows(i)(0).ToString = dataset1.Tables(0).Rows(j)    (0).ToString Then
                    found = True
                End If
            Next
            If found = False Then
                'here you are getting the right result in each loop
                'in this example i'm showing the result in a textbox
                'just change the instruction and write them in your note pad or wherever you want to
                MsgBox(dataset.Tables(0).Rows(i)(0).ToString)
            End If
        Next