Hello. I'm doing project using richtextbox and want to save the contents in Access. But my contents is a list and when I saved it, the list become one line, with a square to space it. Can it actually be done? I set the column with memo type. Here's my code for save it.

sql = "SELECT * FROM RichText"
        da = New OleDb.OleDbDataAdapter(sql, con)
        da.Fill(ds, "RichText")
        Dim cb As New OleDb.OleDbCommandBuilder(da)
        Dim dsnewrow As DataRow

        dsnewrow = ds.Tables("RichText").NewRow()

        dsnewrow.Item("MyOrder") = RichTextBox1.Text

        da.Update(ds, "RichText")

If it can't be done, is there another way? Thank you.

Recommended Answers

All 4 Replies

the sequence of char 10 and 13 isn't correct, this solve it

mytext= Replace(mytext, Chr(13) & Chr(10), Chr(255)) ' this is ok, so save it
    mytext= Replace(mytext, Chr(10), Chr(13) & Chr(10)) 'change the 10-code
    mytext= Replace(mytext, Chr(255), Chr(13) & Chr(10)) ' and set the ok's back

I'm sorry but I don't understand. Where should I put the code? Where is the char in my code?

first : don't use a richtextbox as all the "rich" codes will be to difficult to handle, I can tell you that.

second : if you use a textbox, every line will be ended by a CR (carriage return - remember an old typewriter, where the handle brought you back to the beginning of the line - this is the character 13), and a linefeed (go to next line, character 10)
So the 2 char's (13 and 10) brings you to beginning of the next line.
Textboxes often use only the char(10) code and that will be seen as the little box in Access. So what you need to do is save the correct ones (13 and 10 - just to keep them from changing), change the only 10's to (13 and 10) and set the good ones back.

let's say yout textbox is named textbox1, then you do this :

>dim mytext as string
> the 3 lines I gived earlier
>save mytext to access

now you see neat "next lines" in stead of those boxes in access.

commented: Explained neately. +8

Though I'm not really understand the char thing, it work. It is so neat. Thank you so much! >_<

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.