Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting code for Tek-Tips

Status
Not open for further replies.

Alt255

Programmer
May 14, 1999
1,846
US
I am sure that many of you have aleady done this and I'm just a little slow in catching up. This tiny app consists of a button on a form. You copy a chunk of VB code to the clipboard with CTRL+C, click the button, click in the Tek-Tips message window and press CTRL+V. The code is pasted with proper tab alignment, etc.<br><br>It's hard to show the code because it includes strings used by TGML. Note below that XXXXX denotes a tab surrounded by brackets, YYYYYYY is a bracketed &quot;b&quot; followed by a bracketed &quot;tt&quot;. ZZZZZZZ turns off the &quot;b&quot; and &quot;tt&quot;.<br><br><FONT FACE=monospace><b>Private Sub Command1_Click()<br>TabSize = 2<br>TTpost$ = Clipboard.GetText()<br>If Len(TTpost$) &lt; 1 Then Exit Sub<br>For C = 1 To Len(TTpost$)<br>&nbsp;&nbsp;&nbsp;&nbsp;If Mid$(TTpost$, C, 1) = vbTab Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewPost1$ = NewPost1$ + &quot;XXXXX&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewPost1$ = NewPost1$ + Mid$(TTpost$, C, 1)<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>Next<br>For C = 1 To Len(NewPost1$) - TabSize Step TabSize<br>&nbsp;&nbsp;&nbsp;&nbsp;If Mid$(NewPost1$, C, TabSize) = String$(TabSize, 32) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewPost2$ = NewPost2$ + &quot;XXXXX&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewPost2$ = NewPost2$ + Mid$(NewPost1$, C, TabSize)<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>Next<br>TTpost$ = &quot;YYYYYYY&quot; + Left$(NewPost2$, Len(NewPost2$) - 1) + &quot;ZZZZZZZ&quot;<br>Clipboard.SetText TTpost$, vbCFText<br>End Sub</font></b><br> <p> <br><a href=mailto: > </a><br><a href= plain black box</a><br>
 
P.S. Originally I used the Replace function to substitute bracketed tabs, etc (it made code much shorter), but when the the TGML extentions failed to show up in the message window I assumed it wasn't working. So I did it the old-fashioned way with a For/Next.<br><br>DOH! The message window doesn't show TGML when it's pasted. <p> <br><a href=mailto: > </a><br><a href= plain black box</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top