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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML in multiLine TextBox 1

Status
Not open for further replies.

keenanbr

Programmer
Oct 3, 2001
469
IE
I have gone to the trouble of formatting my text like xml. I then assign it to a multi line text box i.e.

txtMultiLine.Text = myformattedText


if I display it in the immediate window (? txtMultiLine.Text) I see the text as I want it but the displayed text (in the text box) has 8 spaces for every 2 spaces in the immediate window.

Any ideas,
 
Um ... XML itself doesn't really have a format. Perhaps you could show us an example of hat you are talking about.
 
Sorry for the confusion. I am formatting the text with indettation.

Here is what I see in the immediate window

<PostCode>807007</PostCode>
</Address>
</Addresses>
</FrozenClient>
</FrozenClients>
</Illustration>
</CrispDocument>


but in the text box I see


</Address>
</Addresses>
</FrozenClient>
</FrozenClients>
</Illustration>
</CrispDocument>
 
Okey dokey.

The challenge here is related to Tabs. You see, in our wonderful digital world a Tab character in a text string merely tells the text display routines that a Tab is required - but the actual size of the tab tends to depend on additional settings for the output device. In your case the immediate window and the textbox have different tab settings (immediate window tab stops are every 4 characters, textbox default is every 8 characters)

There's not really much you can do about the immediate window, I'm afraid (at least, not without a substantial amount of API work). And the textbox also fails to have a simple way to change the tab settings (again, it can be done but requires use of the API).

So you might want to switch to a richtextbox - which has yet another different set of default tab settings (every 6 characters) from the textbox and the immediate window, but has the facility to change them as we like.

The brief example I include here compares all three outputs in their default mode, and then changes the richtextbox tab settings to that it displays like the immediate window. It isn't a solution to anything, but should give you enough information to reach the result that you want. You'll need a form with a textbox, a richtextbox and two command buttons:
Code:
[blue]Option Explicit

Private Sub Command1_Click()
    Text1.Text = ""
    RichTextBox1.Text = ""
    Text1.Text = "1234567890123456789012" & vbCrLf & vbTab & "." & vbTab & "Hello"
    RichTextBox1.SelText = "1234567890123456789012" & vbCrLf & vbTab & "." & vbTab & "Hello"
    Debug.Print "1234567890123456789012" & vbCrLf & vbTab & "." & vbTab & "Hello"
End Sub

Private Sub Command2_Click()
    RichTextBox1.Parent.ScaleMode = vbCharacters
    RichTextBox1.SelTabCount = 2
    RichTextBox1.SelTabs(0) = 4
    RichTextBox1.SelTabs(1) = 8
End Sub

Private Sub Form_Load()
    Text1.Font = "Courier New"
    Text1.FontSize = 10
    RichTextBox1.Font = "Courier New"
    RichTextBox1.Font.Size = 10
End Sub[/blue]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top