Vb.net writing to HTML file

697 views Asked by At

Massive edit as I've had a fiddle with the code:

So I need to print out a datatable to a text file using vb.net.

This is what I've got so far:

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

However so far all it's printing out is "Courses". I need it to print out all the rows as well. Any idea?

2

There are 2 answers

0
Saleeq Mohammed On

I think a for..each loop will done what you wanted to do.

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

generate , tags inside the for..each loop.

0
Naffel On

I figured out my problem, I was calling this sub at a place where it could not retrieve "selecteduser".