Have a look at the CountTriangles() and TriangleVertex() commands. Also, this:
should be changed to this:
as vertex indices start at 0, not 1.
For v=1 To CountVertices(surf)
should be changed to this:
For v=0 To CountVertices(surf)-1
as vertex indices start at 0, not 1.