我只是遇到了使用VB.NET保存代码的CSV文件的麻烦
我正在尝试保存将在DataGridView中读取的CSV文件。我只是制作了“阅读”代码,它完美无缺!保存文件有什么问题?
Public Class Builder
Sub Create_Records()
Dim i As Integer
For i = 0 To Manager.Grid.Rows.Count - 1
Manager.Grid.Rows.Add("ciao;", "comestai")
Next
End Sub
Sub Write()
If (Not System.IO.Directory.Exists("C:\MyPCBuilder")) Then
System.IO.Directory.CreateDirectory("C:\MyPCBuilder")
End If
Dim Write As New System.IO.StreamWriter("C:\MyPCBuilder\builds.csv")
For i = 0 To Manager.Grid.Rows.Count - 1
Text = ""
For j = 0 To 1
If Text = Text & Manager.Grid.Rows(i).Cells(j).Value & ";" Then
Else
Text = Text & Manager.Grid.Rows(i).Cells(j).Value
End If
Next
Write.WriteLine(Text)
Next
Write.Close()
End Sub
Private Sub btn_Confirm_Click(sender As Object, e As EventArgs) Handles btn_Confirm.Click
Create_Records()
Write()
End Sub
结束班
答案 0 :(得分:1)
内循环中的If语句错误。 <systemSuffix systemIdSuffix="example.dtd"
uri="models/example/example.dtd"/>
部分为空,条件很奇怪。由于您只有2列,只需编写
Exception in thread "pool-1-thread-1" java.lang.NullPointerException
at java.net.URI$Parser.parse(URI.java:3042)
at java.net.URI.(URI.java:588)
at org.xmlresolver.ResourceConnection.(ResourceConnection.java:42)
at org.xmlresolver.ResourceResolver.cacheStreamSystem(ResourceResolver.java:172)
at org.xmlresolver.ResourceResolver.resolveEntity(ResourceResolver.java:296)
at org.xmlresolver.Resolver.resolveEntity(Resolver.java:186)
at org.apache.xerces.util.EntityResolver2Wrapper.resolveEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityManager.resolveEntity(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:451)
at net.sf.saxon.event.Sender.send(Sender.java:179)
at net.sf.saxon.Configuration.buildDocumentTree(Configuration.java:3808)
at net.sf.saxon.s9api.DocumentBuilder.build(DocumentBuilder.java:369)
at net.sf.saxon.s9api.DocumentBuilder.build(DocumentBuilder.java:385)
如果你想保留这个内部循环(如果你有更多列或可变数量的列),请测试索引(外部循环未显示)
Then