-- 作者:有点甜
-- 发布时间:2014/9/18 20:17:00
--
Dim dlg As new OpenFileDialog dlg.Filter = "文本文件|*.txt"
If dlg.ShowDialog = DialogResult.OK Then Dim strs As String = FileSys.ReadAllText(dlg.FileName,Encoding.Default) Dim rs() As String = strs.Split(vbcrlf) \'txt的总行数 Dim k2 As String = rs(2).trim For i As Integer = 1 To rs.Length - 2 \'从第2行开始读取 Dim cs() As String = rs(i).Split("^") \'判断总列数 Dim cs9 As Double = val(cs(9).trim.Replace(",", "")) Dim cs10 As Double = val(cs(10).trim.Replace(",", "")) Dim dd As DataRow = DataTables("表A").Find("交易日期 = #" & cs(1).trim & "# And 收入 = " & cs9 & " And 支出 = " & cs10 & "") If dd Is Nothing Then Dim dr As DataRow = DataTables("表A").Addnew() For j As Integer = 0 To cs.Length -1 dr("交易日期") = cs(1).trim dr("收入") = cs9 dr("支出") = cs10 Next End If Next End If
|