View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Desmond Walsh Desmond Walsh is offline
external usenet poster
 
Posts: 28
Default Problem encountered with Debug.Print message being passed to subroutine

On Wednesday, November 7, 2018 at 4:54:30 PM UTC-5, GS wrote:
Note that using vbTab applies the tab spacing set on the VBE OptionsGeneral
tab, whereas using the Space() function allows you to specify the spacing
between string sets.

I have the following function that accepts an Integer arg for the spacing I
want to use between sections when building strings. I also know that "Tab" is a
keyword and so have no idea why I didn't pick up on that; - sory, my bad!

So...

Public Function SetTab$(iLen%)
' Returns a set length string of spaces
' Args: iLen% The number of spaces

SetTab = Space(iLen)
End Function 'SetTab()

..and I use it like so...

Sub test_SetTab()
Dim s1$
s1 = "A" & vbTab & "B" & vbTab & "C"
Debug.Print s1
s1 = "Part1:" & SetTab(10) & "Part2;" & SetTab(5) & "Part3!"
Debug.Print s1
End Sub

..which returns the following:

A B C
Part1: Part2; Part3!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


Thank you for your posting. However, I have found the Tab() and Spc() functions very useful in formatting Debug.Print output. I have now concluded that it is not possible to put a Debug.Print message containing those function calls into a string and have that string output by Debug.Print and expect the formatting to be implemented.

I have developed a strategy to overcome this limitation. Please check my next posting for details.