ASP.NET Programming

It’s a tough job but somebody has to do it. Seriously though, coding can be a very enjoyable creative process. It can also be a complete pain and sometimes deliriously tedious! As a professional ASP.NET Programmer I’ve written a lot of code, some of which I am very proud (or at least was at the time I wrote it!).

If you’ve never seen .NET programming, I’m posting a little appetizer here for you now. My sincere apologies if you find this sleep inducing 🙂 and the formatting is not very neat in this html editor but you will at least see what it looks like and realize that all programmers must be somewhat insane…

Private Function InsertBreaksForWrapping(ByVal sb As System.Text.StringBuilder, _
ByRef curPos As Integer, _
ByRef newPos As Integer, _
ByRef curLength As Integer, _
ByVal iLength As Integer, _
Optional ByVal EOF As Boolean = False)
As System.Text.StringBuilder

Try
If Not EOF Then
‘the long text is within the string so…
Do While curLength > iLength
sb.Insert(curPos + iLength, vbCrLf)
curPos += iLength

‘set the new position in the string
newPos = sb.ToString.IndexOf(” “, curPos + 1)

If newPos = -1 Then Exit Do

‘calculate the length of this piece
curLength = newPos – (curPos + 1)
Loop
Else
‘this is an eof position so…
Do While (sb.ToString.Length – curPos) > iLength
sb.Insert(curPos + iLength, vbCrLf)
curPos += iLength
Loop
End If

‘return stringbuilder
Return sb

Catch ex As Exception
End Try
End Function

, , , , , , , , ,

No comments yet.

Leave a Reply