add string at end of rtf property of RichEditBox

S

Sandra Setz

Hi,

Can someone explain to me why it isn't possible to add strings after the rtf
property of a RichEditBox? For example, I am trying to create an SQL string
as
follows:

Dim sSQL As String = "UPDATE tblRecipe SET Preparation='" &
txtPreparation.Rtf & "' WHERE Id=35"

For some reason, the text after the Rtf property is not added to the string
sSQL. What is it I am doing wrong? Is there another way I can build this
query?

Thanks in advance,
Sandra
 
H

Herfried K. Wagner [MVP]

* "Sandra Setz said:
Can someone explain to me why it isn't possible to add strings after the rtf
property of a RichEditBox? For example, I am trying to create an SQL string
as
follows:

Dim sSQL As String = "UPDATE tblRecipe SET Preparation='" &
txtPreparation.Rtf & "' WHERE Id=35"

Are you sure you are not looking for the 'Text' property?
For some reason, the text after the Rtf property is not added to the string
sSQL. What is it I am doing wrong? Is there another way I can build this
query?

Maybe the string contained in the 'Rtf' property ends with a null
character. When appending the text, the IDE and/or message box and/or
some controls won't show the whole string because they think it ends at
the null character.
 
S

Sandra Setz

Can someone explain to me why it isn't possible to add strings after the
rtf
Are you sure you are not looking for the 'Text' property?

No, since I want to save the rtf-format into the database as well, so I need
the rtf property.
Maybe the string contained in the 'Rtf' property ends with a null
character. When appending the text, the IDE and/or message box and/or
some controls won't show the whole string because they think it ends at
the null character.

Mmm, how do I check this?

Sandra
 
S

Sandra Setz

Use txtPreparation.Text instead.

But then I don't save the rtf-formatting, and that's what I want.

Sandra
 
H

Herfried K. Wagner [MVP]

* "Sandra Setz said:
Mmm, how do I check this?

You can use 'InStr' or the string's 'IndexOf' method to search for
'ControlChars.NullChar'. If it's part of the string, you can use 'Mid'
or the string's 'Substring' method to get the part of the string without
the null character. After getting rid of this character (if it is part
of the string), concatenate the other string to the end.
 
S

Sandra Setz

You can use 'InStr' or the string's 'IndexOf' method to search for
'ControlChars.NullChar'. If it's part of the string, you can use 'Mid'
or the string's 'Substring' method to get the part of the string without
the null character. After getting rid of this character (if it is part
of the string), concatenate the other string to the end.

Yeah, this was the problem. Thanks. It seems to work now.

Sandra
 
H

Herfried K. Wagner [MVP]

* "Sandra Setz said:
You can use 'InStr' or the string's 'IndexOf' method to search for
'ControlChars.NullChar'. If it's part of the string, you can use 'Mid' [...]
Yeah, this was the problem. Thanks. It seems to work now.

Thanks for confirming that!
 
S

Sandra Setz

Herfried K. Wagner said:
* "Sandra Setz said:
You can use 'InStr' or the string's 'IndexOf' method to search for
'ControlChars.NullChar'. If it's part of the string, you can use 'Mid'
[...]
Yeah, this was the problem. Thanks. It seems to work now.

Thanks for confirming that!

You're welcome ;-)

Sandra
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top