Richtexbox probleme

cs_jackky Messages postés 50 Date d'inscription mardi 8 janvier 2002 Statut Membre Dernière intervention 6 juillet 2003 - 3 janv. 2003 à 07:36
cs_jackky Messages postés 50 Date d'inscription mardi 8 janvier 2002 Statut Membre Dernière intervention 6 juillet 2003 - 3 janv. 2003 à 14:24
bonjour dans un richtext box jai un text numerique

du genre

456 456 25 335 845 142674 43 21454 56 24 84
84 65 32 51 64 987 5341 87 64 231
321 585 2 8 4 685 54 59 357442 59

et je voudrais mettre les chiffres "59" en rouge

un ami m'a conseiller ca, mais cela ne fonctionne pas

Private Sub Command1_Click()
For i = 1 To Len(RichTextBox1) Step 2
If Mid$(RichTextBox1.Text, i, 2) = "59" Then
RichTextBox1.SelStart = i
RichTextBox1.SelLength = 2

RichTextBox1.SelColor = vbRed
Next
End Sub

pouvez vous m'aider svp

7 réponses

ShareVB Messages postés 2676 Date d'inscription vendredi 28 juin 2002 Statut Membre Dernière intervention 13 janvier 2016 26
3 janv. 2003 à 08:03
salut

il suffit de remplacer
ton code
par

'les commentaires commentent les erreurs
Private Sub Command1_Click()
Dim i As Long
For i = 1 To Len(RichTextBox1.Text) 'incrementer seulement de 1;spécifier .Text
If Mid$(RichTextBox1.Text, i, 2) = "59" Then
RichTextBox1.SelStart = i - 1
RichTextBox1.SelLength = 2

RichTextBox1.SelColor = vbRed
End If ' ne pas oublier les End If des If...Then en plusieurs lignes
Next
End Sub

voila

ShareVB
0
cs_alfo Messages postés 3 Date d'inscription vendredi 27 décembre 2002 Statut Membre Dernière intervention 30 septembre 2004
3 janv. 2003 à 08:13
-------------------------------
Réponse au message :
-------------------------------

> bonjour dans un richtext box jai un text numerique
>
> du genre
>
> 456 456 25 335 845 142674 43 21454 56 24 84
> 84 65 32 51 64 987 5341 87 64 231
> 321 585 2 8 4 685 54 59 357442 59
>
> et je voudrais mettre les chiffres "59" en rouge
>
> un ami m'a conseiller ca, mais cela ne fonctionne pas
>
> Private Sub Command1_Click()
> For i = 1 To Len(RichTextBox1) Step 2
> If Mid$(RichTextBox1.Text, i, 2) = "59" Then
> RichTextBox1.SelStart = i
> RichTextBox1.SelLength = 2
>
> RichTextBox1.SelColor = vbRed
> Next
> End Sub
>
> pouvez vous m'aider svp
>
>
>
> Bonjour, voici la solution à ton problème:

Private Sub Command1_Click()

For i = 1 To Len(RichTextBox1.Text) Step 1
If Mid$(RichTextBox1.Text, i, 2) = "59" Then
RichTextBox1.SelStart = i - 1
RichTextBox1.SelLength = 2

RichTextBox1.SelColor = vbRed
End If

Next i

End Sub
0
VicoLaChips2 Messages postés 436 Date d'inscription dimanche 20 janvier 2002 Statut Membre Dernière intervention 2 février 2010 2
3 janv. 2003 à 14:03
Bonjour -;)

Ben moi j'ai aussi une soluce...

Private Sub Form_Load()
Dim strTmp As String, tblVal() As String, i As Integer
Open "c:\fictest.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, strTmp
tblVal = Split(strTmp, " ")
For i = 0 To UBound(tblVal)
If Trim(tblVal(i)) = "59" Then MsgBox "YA BON LE 59 + 10 !!"

Next
Loop
End Sub

'Bien sur ça ne correspond peut être pas à la réponse idéale... mais bon !!

@+, VIC
0
VicoLaChips2 Messages postés 436 Date d'inscription dimanche 20 janvier 2002 Statut Membre Dernière intervention 2 février 2010 2
3 janv. 2003 à 14:12
Euhh.. encore moi !!
Plus sérieusement .

Option Explicit

Private Sub Command1_Click()
Dim i As Integer
For i = 1 To Len(rtf.Text)
If Mid(rtf.Text, i, 2) = "59" Then
MsgBox "Super le 59 + 10 !!"
End If
Next
End Sub

Private Sub Form_Load()
rtf.Text = "456 456 25 335 845 142674 43 21454 56 24 84" & _
"84 65 32 51 64 987 5341 87 64 231" & _
"321 585 2 8 4 685 54 59 357442 59"

End Sub

'Bien sur c'est peut être pas encore tout à fait la réponse... !!

@+, VIC
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
VicoLaChips2 Messages postés 436 Date d'inscription dimanche 20 janvier 2002 Statut Membre Dernière intervention 2 février 2010 2
3 janv. 2003 à 14:13
euuhhh .. c'était quoi la question ???
0
VicoLaChips2 Messages postés 436 Date d'inscription dimanche 20 janvier 2002 Statut Membre Dernière intervention 2 février 2010 2
3 janv. 2003 à 14:20
SORRY !!

Option Explicit

Private Sub Command1_Click()
Dim i As Integer
For i = 1 To Len(rtf.Text)
If Mid(rtf.Text, i, 2) = "59" Then
rtf.SelStart = i - 1
rtf.SelLength = 2
rtf.SelColor = vbRed
End If
Next
End Sub

Private Sub Form_Load()
rtf.Text = "456 456 25 335 845 142674 43 21454 56 24 84" & _
"84 65 32 51 64 987 5341 87 64 231" & _
"321 585 2 8 4 685 54 59 357442 59"

End Sub

@+, VIC
0
cs_jackky Messages postés 50 Date d'inscription mardi 8 janvier 2002 Statut Membre Dernière intervention 6 juillet 2003
3 janv. 2003 à 14:24
wow merci a tous ceux qui ont repondu c vraiment super
je vous remercie beaucoupvous etes bien sympa

en fais je travail sur un projet personnel et puis je voulais decryter se qui pass par le port serie et le message a un bit de start de 59 59 59 59 59 ,
mais ya aussi plusieur chose sur cette frequence c pour cela que je voulais mettre les 59 en rouge,

merci beaucoup

c vraiment super vb france
0
Rejoignez-nous