Started coding a table mod but don't know how to code some things any help would be appreciated. Places I need help are commented in red. Any improvements are also welcome.
function ChkTable(ByVal fString)
Dim Counter
Dim tblopen
Dim tropen
Dim tdopen
Dim go
tblopen=0
tropen=0
tdopen=0
go=1
ChkTable = fString
for Counter = 1 To UBound(fString)
if tblopen > 0 then
if tblopen=tropen then
if tropen=tdopen then
if UCase(Right(strArray(Counter-1), 7)) = "[TABLE]" then
'replace [TABLE] with <table>
tdopen--
end if
if UCase(Right(strArray(Counter-1), 5)) = "[/TD]" then
'replace [/TD] with </td>
tdopen--
end if
else
if UCase(Right(strArray(Counter-1), 4)) = "[TD]" then
'replace [TD] with <td>
tdopen++
end if
if UCase(Right(strArray(Counter-1), 5)) = "[/TR]" then
'replace [/TR] with </tr>
tropen--
end if
end if
'code something that will delete anything else (not necessary)
else
if UCase(Right(strArray(Counter-1), 4)) = "[TR]" then
'replace [TR] with <tr>
tropen++
end if
if UCase(Right(strArray(Counter-1), 8)) = "[/TABLE]" then
'replace [/TABLE] with </table>
tblopen--
end if
'code something that will delete anything else (not necessary)
end if
else
if UCase(Right(strArray(Counter-1), 7)) = "[TABLE]" then
'replace [TABLE] with <table>
tblopen++
end if
end if
next
'Close all open tags
Do While go=1
if tblopen>0 then
if tropen>tblopen then
if tdopen>tropen then
'add </td> to end of string
else
'add </tr> to end of string
end if
else
'add </table> to end of string
end if
else
go=0
end if
Loop
end function
Edit #1: Fixed mistake #1<