Question How do i use new line or tab in sql DB with visual basic 2010

Sythe

Member
Joined
Jul 18, 2012
Messages
13
Programming Experience
Beginner
Hi, I would like to insert table of contents into the DB and show it in form with only 1 label. All text are in one field of database only. The text should include new lines.
something like:
------------------
Table of Contents


Introduction
Background tabgoeshere 2-1
Background tabgoeshere 2-2

------------------


I am using varchar(max) and this is what i got so far..


53a6f3745b.png



TIA

Sorry if i posted on the wrong section :s
 
Last edited:
You don't have to do anything special. Line breaks are simply carriage return and line feed characters and a Tab is just a tab character. They are no different to any other characters when it comes to storage. You treat a String that contains line breaks and Tabs in exactly the same way as you do any other String.

When it comes time to display, there's no issue with the line breaks but there is with Tabs. Label's do not render Tab characters and, as far as I'm aware, you cannot make them do so. You could replace the Tabs with a set number of spaces, but the width of a space depends on the Font, so that might be an issue. You could use a ReadOnly TextBox or you could use GDI+ to render the text yourself and therefore choose the horizontal placement of each line.
 
Thanks for trying to help i appreciate it but with my little knowledge of VB.net sorry i am having a hard time understanding what you just posted there :3.

What i am doing now is to output the data on a textbox that is set its multiline property to true. The problem where i can see it is that when i copy the data that is on a notepad and paste it on the database it only paste the first line.
 
Back
Top