Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog dlg.InitialDirectory ="E:\A0File\" dlg.Filter= "所有文件|*.*" '设置筛选器 If dlg.ShowDialog = DialogResult.Ok Then Dim S As String = FileSys.ReadAllText(dlg.FileName) Dim mmID As String =s.SubString(0,5) output.show (mmID) Dim mmDate As Date Dim dr As DataRow Dim mmYM As String =s.SubString(28,4) & "-" & s.SubString(33,2) & "-" Dim ss As String ss=s.Remove(0,s.LastIndexOf("T0")+3) ss=ss.Remove(ss.IndexOf("=")) Dim s2() As String =ss.Split(chr(13)) OutPut.show(s2.Length) For i As Integer =0 To s2.Length-1 Dim s3() As String =s2(i).Split(" ") If s3(0) > "" AndAlso s3(1) > "" AndAlso s3(2) > "" Then mmDate =Cdate(mmYM & (i+1)) Dim rr As String = "mID = '" & mmID & "' And mDate = " & "#" & mmDate & "#" dr = DataTables("WeatherData").Find(rr) If dr IsNot Nothing Then Dim r As Integer r = Tables("WeatherData").FindRow(rr, 0, True ) If r >= 0 Then '如果找到的话 Tables("WeatherData").Position = r '定位到找到的行. End If Tables("WeatherData").Current("mT02")=s3(0) Tables("WeatherData").Current("mT08")=s3(1) Tables("WeatherData").Current("mT14")=s3(2) Tables("WeatherData").Current("mT20")=s3(3) Tables("WeatherData").Current("mGt")=s3(4) Tables("WeatherData").Current("mDt")=s3(5) Else DataTables("WeatherData").AddNew() Tables("WeatherData").Position=Tables("WeatherData").Position+1 Tables("WeatherData").Current("mID")=mmID Tables("WeatherData").Current("mDate")=mmDate Tables("WeatherData").Current("mT02")=s3(0) Tables("WeatherData").Current("mT08")=s3(1) Tables("WeatherData").Current("mT14")=s3(2) Tables("WeatherData").Current("mT20")=s3(3) Tables("WeatherData").Current("mGt")=s3(4) Tables("WeatherData").Current("mDt")=s3(5) End If End If Next Else MessageBox.Show("你未选择任何文件" ,"提示") '提示用户选择的文件 End If
|