OVH Cloud OVH Cloud

RichTextBox

3 réponses
Avatar
Cedric
Bonjour,

J'ai un mystere dans ces deux lignes de codes (vb .net) :

dim Chaine as string
Chaine = RichTextBox1.Rtf & "xxx"


Contenu de Chaine apres execution : contenu de l'objet
RichTextBox mais pas de xxx ?????

Merci.

3 réponses

Avatar
ng
SAlut,

C'est curieux chez moi ce problème ne se produit pas (vb8) :

Dim strChaine As String
strChaine = RichTextBox1.Rtf & "xxx"
MessageBox.Show(strChaine)

Renvoit bien :
---------------------------

---------------------------
{rtf1ansiansicpg1252deff0deflang1036{fonttbl{f0fnilfcharset0
Microsoft Sans Serif;}}

viewkind4uc1pardf0fs17par

}

xxx
---------------------------
OK
---------------------------

Attention la propriété rtf renvoit la mise en forme, pour obtenir le texte
seul il faut utiliser la prpriété Text :

Dim strChaine As String
strChaine = RichTextBox1.Text & "xxx"
MessageBox.Show(strChaine)

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/



Cedric a écrit :

Bonjour,

J'ai un mystere dans ces deux lignes de codes (vb .net) :

dim Chaine as string
Chaine = RichTextBox1.Rtf & "xxx"


Contenu de Chaine apres execution : contenu de l'objet
RichTextBox mais pas de xxx ?????

Merci.


Avatar
Cedric
Merci pour la reponse ! c'est quelle version vb8 ?

J'ai fait d'autres essais, et en fait, le richtextbox
contient comme dernier caractere le code 0 qui doit couper
la chaine.

Le code suivant semble marcher :

Dim strChaine As String
strChaine = RichTextBox1.Rtf.SubString(0,
RichTextBox1.Rtf.Length - 1) & "xxx"
MessageBox.Show(strChaine)

Avec la propriete Text, pas de pb !!!

Merci.
Avatar
AlexC
il y a une différence entre la propriété "Text" et "Rtf" du RichTextbox ....
la propriété Rtf correspond au code RTF de la propriété Text ...
exemple :

Si vous mettez "Salut" dans la propriété Text vous vous retrouverez avec
ceci dans la propriété Rtf :

{rtf1ansiansicpg1252deff0deflang1036{fonttbl{f0fnilfcharset0
Microsoft Sans Serif;}}
viewkind4uc1pardf0fs17 Salutpar
}

il faut tenir compte des nombreux tags du code RTF on peux pas le modifier
comme ca ... si vous ecrivez kkechose après le "}" ca ne s'affichera pas !
vu qu'il indique la fin du fichier RTF

"Cedric" a écrit dans le message de
news: b81101c48906$7d52bd40$

Merci pour la reponse ! c'est quelle version vb8 ?

J'ai fait d'autres essais, et en fait, le richtextbox
contient comme dernier caractere le code 0 qui doit couper
la chaine.

Le code suivant semble marcher :

Dim strChaine As String
strChaine = RichTextBox1.Rtf.SubString(0,
RichTextBox1.Rtf.Length - 1) & "xxx"
MessageBox.Show(strChaine)

Avec la propriete Text, pas de pb !!!

Merci.