如何编译一个类呀?
nnh 2006-04-07 09:59:27 有一个新类,名为CSVHelper,它的源文件为:
CSVHelper.vb
===============
Public Class CSVHelper
Public Function Export(ByVal ds As DataSet, ByVal exportcolumnheadings As Boolean) As String
Dim header As String
Dim body As String
Dim record As String
If exportcolumnheadings Then
For Each col As DataColumn In ds.Tables(0).Columns
header = header & Chr(34) & col.ColumnName & Chr(34) & ","
Next
header = header.Substring(0, header.Length - 1)
End If
For Each row As DataRow In ds.Tables(0).Rows
Dim arr() As Object = row.ItemArray()
For i As Integer = 0 To arr.Length - 1
If arr(i).ToString().IndexOf(",") > 0 Then
record = record & Chr(34) & arr(i).ToString() & Chr(34) & ","
Else
record = record & arr(i).ToString() & ","
End If
Next
body = body & record.Substring(0, record.Length - 1) & vbCrLf
record = ""
Next
If exportcolumnheadings Then
Return header & vbCrLf & body
Else
Return body
End If
End Function
End Class
在web.aspx页的web.aspx.vb中是这样声明的:
Dim csv As New CSVHelper
Dim strData As String = csv.Export(ds, CheckBox1.Checked)
请问我要怎样做才可使用这个CSVHelper类呀?我在DOS提示符下用:
vbc /t:library /r:System.dll /r:System.Data.dll CSVHelper.vb
老是提示未定义类型dataset,datacolumn,datarow
谢谢了.