Vb.net写入HTML文件

Vb.net写入HTML文件,vb.net,datatable,Vb.net,Datatable,大量编辑,因为我对代码进行了修改: 因此,我需要使用vb.net将数据表打印到文本文件中 到目前为止,我得到的是: Public Shared Sub WriteCode() Dim index As String = "\\ndrive\by006946\My Documents\Business Programming\Web Server Root\index.html" Dim Introduction As String = "<html><b>

大量编辑,因为我对代码进行了修改:

因此,我需要使用vb.net将数据表打印到文本文件中

到目前为止,我得到的是:

Public Shared Sub WriteCode()
    Dim index As String = "\\ndrive\by006946\My Documents\Business Programming\Web Server Root\index.html"
    Dim Introduction As String = "<html><b>Welcome! Here are your subscribed classes:</b></html>"
    Dim selecteduser As String = LoginPage.UserNameBox.Text

    If System.IO.File.Exists(index) = True Then
        Dim objwriter As New System.IO.StreamWriter(index)
        Dim courses As New DataSet
        courses = GetUserCourses(selecteduser)
        Dim subclasses As DataTable = New DataTable("Courses")
        subclasses.Columns.Add("Course Name")

        Dim count As Integer
        count = CountRecords() - 1
        For i As Integer = 0 To count
            subclasses.Rows.Add(courses.Tables(0).Rows(i).Item(0)) 'Displays all the users subscribed courses
        Next

        objwriter.Write(subclasses.)
        objwriter.Close()

    End If

End Sub
公共共享子写代码()
Dim index As String=“\\ndrive\by006946\My Documents\Business Programming\Web Server Root\index.html”
Dim Introduction As String=“欢迎!以下是您订阅的课程:”
Dim selecteduser As String=LoginPage.UserNameBox.Text
如果System.IO.File.Exists(index)=True,则
Dim objwriter作为新的System.IO.StreamWriter(索引)
Dim课程作为新数据集
课程=GetUserCourses(selecteduser)
作为DataTable的Dim子类=新DataTable(“课程”)
子类.列.添加(“课程名称”)
将计数设置为整数
count=CountRecords()-1
对于i作为整数=0进行计数
“subclass.Rows.Add(courses.Tables(0).Rows(i).Item(0))”显示所有用户订阅的课程
下一个
objwriter.Write(子类)
objwriter.Close()
如果结束
端接头

然而,到目前为止,所有打印出来的都是“课程”。我也需要它来打印所有的行。有什么想法吗?

我想,for..每个循环都会完成你想做的事情

for each row as datarow in subclassea.rows

 row.item(0).value ' will help u to get value from first cell of each row on iteration.

next

生成,for..each循环中的标签。

我解决了问题,在无法检索“selecteduser”的位置调用此sub