HTML generation what's wrong with this code

I am trying to generate a table with this code. It contains 9 column.

WHile the data is there when I printed it to a text file, the html was out bizarre. Please help

Sub Initialize

Dim s As New NotesSession

Dim dbCurrent As NotesDatabase

Dim dbMain As NotesDatabase

Dim doc As NotesDocument

Dim	TeamAssCollection	As NotesDocumentCollection

Dim TeamDoc As NotesDocument

Dim AsscDoc As NotesDocument

Dim numberItem As NotesItem

Set dbCurrent= s.CurrentDatabase

serverName=dbCurrent.Server

Dim Assview As NotesView

Dim AssmDB As NotesDatabase

Dim i As Integer

Dim sInfo As String

Dim cInfo As  String

Set doc=s.DocumentContext

classInfo=doc.ClassInfo(0)

'classInfo="P02-1648"

Path$ = fGeneratePath( "" )

Set dbMain = s.GetDatabase(serverName, Path$ +"ielsmain.nsf")

Set AssmDB =s.GetDatabase(serverName, Path$ +"ielsassess.nsf")

Dim vTeamList As Variant

Dim view As NotesView

Dim Marks As Double

Dim item As NotesItem

Dim htmlrow As String

Set mainView=dbMain.getview("TeamByClass")

Set Assview=dbcurrent.getview("MentorTraitAssByStudentNo")

Set Assview1=dbcurrent.GetView("AssesComputationView")

Set Assview2=dbcurrent.GetView("OutcomeAss")	

Set TeamDocsCollection=mainView.getalldocumentsbykey(classInfo, True)

Set TeamDoc=TeamDocsCollection.getfirstdocument

htmlstart= "<Table>"

While Not TeamDoc Is Nothing

	TeamID=TeamDoc.teamID(0)

	If TeamDoc.Form(0)<>"team formation" Then

		Set TeamDoc=TeamDocsCollection.getnextdocument(teamdoc)

	Else

		'Count How many members there are in the team

		TeamMemberList=TeamDoc.StudentNotesNameList

		StudentNoList=TeamDoc.StudentNoList

		TeamName=TeamDoc.TeamName(0)

		Fullname=TeamDoc.StudentFullNameList

		For i=0 To Ubound(teamMemberList)

			Set MentorTraitDoc=Assview.GetDocumentByKey(StudentNoList(i), True)

			If Not MentorTraitDoc Is Nothing Then

				IEValue1=MentorTraitDoc.IETraitvalue_1(0)

				IEValue2=MentorTraitDoc.IETraitvalue_2(0)

				IEValue3=MentorTraitDoc.IETraitvalue_3(0)				

				IEValue4=MentorTraitDoc.IETraitvalue_4(0)

				IEValue5=MentorTraitDoc.IETraitvalue_5(0)

				IEValueTotal#=Cint(IEValue1)+Cint(IEvalue2)+Cint(IEValue3)+Cint(IEValue4)+Cint(IEValue5)

				IEValueTotalRaw=Cint((IEValueTotal#/50*60))

				htmlrow=htmlrow+ "<tr><td width=80>"+Cstr(IEValue1)+"<td width=80>"+Cstr(IEValue2)+"<td width=80>"+Cstr(IEValue2)+"<td width=80>"+Cstr(IEValue3)+"<td width=80>"+Cstr(IEValue4)+"<td width=80>"+Cstr(IEValue5)+"<td width=80>"+Cstr(IEValueTotal#)+"</td>|"

			Else

				htmlrow=htmlrow+"<tr><td width=80>&nbsp;<td width=80>&nbsp;<td width=80>&nbsp;<td width=80>&nbsp;<td width=80>&nbsp;<td width=80>&nbsp;<td width=80>&nbsp;</td>"

			End If

			Set PeerComponentDoc=Assview1.GetDocumentbyKey(StudentNoList(i))

			If Not PeerComponentDoc Is Nothing Then

				PeerComponent=PeerComponentDoc.Score(0)

			Else

				Peercomponent="&nbsp'"

			End If

			Set OutcomeDoc=Assview2.GetDocumentbyKey(TeamID)

			If Not OutcomeDoc Is Nothing Then

				OutcomeScore=OutcomeDoc.TotalMark(0)

			Else

				OutcomeScore="&nbsp'"

			End If

			htmlrow=htmlrow+"<td width=80>"+Cstr(IEValueTotalRaw)+"<td width=80>"+Cstr(Peercomponent)+"<td width=80>"+Cstr(OutcomeScore)+"<td>"

			Textfile=Textfile+"*"+StudentNoList(i)+";"+ FullName(i)+";"+IEValue1+";"+ IEValue2+";"+IEValue3+";"+IEValue4+";"+IEValue5+";"+Cstr(IEValueTotalRaw)+";"+Cstr(IEvalueTotalRaw)+";"+Cstr(PeerComponent)+";"+Cstr(OutcomeScore)

		Next i

	End If

	Set TeamDoc=TeamDocsCollection.getnextdocument(teamdoc)

Wend

HtmlBody=Htmlstart+htmlorw+"</table>"

Print HTMLBody

End Sub

Subject: HTML generation what’s wrong with this code

It might be worth getting an HTML validator.

Ultraedit32 text editor has TIDY HTML validator built into it; very useful for this type of debugging.

Subject: HTML generation what’s wrong with this code

Could be that some rows contain seven cells and some only three with no colspan indication. If you aren’t using all of the cells in some rows, put in blanks.

Subject: HTML generation what’s wrong with this code

You have nested tags in ways you should not. For example:

htmlrow=htmlrow+“”+Cstr(IEValueTotalRaw)+“”+Cstr(Peercomponent)+“”+Cstr(OutcomeScore)+“”

That isn’t valid HTML. Where are the ends of the cells?

Subject: RE: HTML generation what’s wrong with this code

They aren’t actually required in the “loose” DTD, Ben – but the one at the end of each row may be throwing things for a loop. I always use and explicitly, by the way, just to make sure the browser can’t get creative about interpreting things.

Subject: RE: HTML generation what’s wrong with this code

You learn something new every day. I assumed they were required, even under the loose DTD. Thanks!