blatchoskof
Messages postés2Date d'inscriptionsamedi 1 octobre 2005StatutMembreDernière intervention 8 octobre 2005
-
8 oct. 2005 à 14:47
blatchoskof
Messages postés2Date d'inscriptionsamedi 1 octobre 2005StatutMembreDernière intervention 8 octobre 2005
-
8 oct. 2005 à 17:19
Voila j 'essaie de faire un ocx qui pourra avec une phrase me sortir le
n ieme mot, du genre monocx.mot(1) = le premier mot de ma phrase.Je me
suis inspiré d'un code donne sur VBFrance qui permettait d obtenir le
nombre de mot d'une phrase. j ai commencé, mais le probleme c que je
créée des textbox pour mes mot et ca limite mon champs d'action. ex :
si je demande le mot 1000 ca risque de me causer des problemes car je
dois alors creer 1000 textbox....breff si vous pouviez me montrer
comment simplifier mon code ca me serait utile.<sup>
voila mon code certes tres long ....
Public Function m()
Dim lettre(1000000) As String
Dim nbrmots As Integer
Dim nombreL As Integer
Text0.Text = 0
Text1.Text = 0
Text2.Text = 0
Text3.Text = 0
Text4.Text = 0
Text5.Text = 0
Text6.Text = 0
Text7.Text = 0
Text8.Text = 0
Text9.Text = 0
Text10.Text = 0
nbrmots = 0
Texte.Text = Texte.Text & " ¤£¤"
For x = 1 To 99999
lettre(x) = Mid(Texte.Text, x, 1)
If Mid(Texte.Text, x + 3, 3) = "¤£¤" Then
nombreL = x + 4
End If
Next x
Texte.SetFocus
For t = 0 To (nombreL - 4)
SendKeys "{right}"
Next t
SendKeys "{delete}"
SendKeys "{delete}"
SendKeys "{delete}"
SendKeys "{delete}"
For x = 1 To nombreL
If lettre(x) " " Then nbrmots nbrmots + 1
If lettre(x) " " And nbrmots 1 Then Text1.Text = x
If lettre(x) " " And nbrmots 2 Then Text2.Text = x
If lettre(x) " " And nbrmots 3 Then Text3.Text = x
If lettre(x) " " And nbrmots 4 Then Text4.Text = x
If lettre(x) " " And nbrmots 5 Then Text5.Text = x
If lettre(x) " " And nbrmots 6 Then Text6.Text = x
If lettre(x) " " And nbrmots 7 Then Text7.Text = x
If lettre(x) " " And nbrmots 8 Then Text8.Text = x
If lettre(x) " " And nbrmots 9 Then Text9.Text = x
If lettre(x) " " And nbrmots 10 Then Text10.Text = x
nbrm.Text = nbrmots
Next x
If Text1.Text > 0 Then Text0.Text = Mid(Texte.Text, 1, (Text1.Text - 1))
If Text2.Text > 0 Then Text1.Text Mid(Texte.Text, Text1.Text + 1, (Text2.Text - 1 - Text1.Text)) Else Text1.Text 0
If Text3.Text > 0 Then Text2.Text Mid(Texte.Text, Text2.Text + 1, (Text3.Text - 1 - Text2.Text)) Else Text2.Text 0
If Text4.Text > 0 Then Text3.Text Mid(Texte.Text, Text3.Text + 1, (Text4.Text - 1 - Text3.Text)) Else Text3.Text 0
If Text5.Text > 0 Then Text4.Text Mid(Texte.Text, Text4.Text + 1, (Text5.Text - 1 - Text4.Text)) Else Text4.Text 0
If Text6.Text > 0 Then Text5.Text Mid(Texte.Text, Text5.Text + 1, (Text6.Text - 1 - Text5.Text)) Else Text5.Text 0
If Text7.Text > 0 Then Text6.Text Mid(Texte.Text, Text6.Text + 1, (Text7.Text - 1 - Text6.Text)) Else Text6.Text 0
If Text8.Text > 0 Then Text7.Text Mid(Texte.Text, Text7.Text + 1, (Text8.Text - 1 - Text7.Text)) Else Text7.Text 0
If Text9.Text > 0 Then Text8.Text Mid(Texte.Text, Text8.Text + 1, (Text9.Text - 1 - Text8.Text)) Else Text8.Text 0
If Text10.Text > 0 Then Text9.Text Mid(Texte.Text, Text9.Text + 1, (Text10.Text - 1 - Text9.Text)) Else Text9.Text 0
cs_DARKSIDIOUS
Messages postés15814Date d'inscriptionjeudi 8 août 2002StatutMembreDernière intervention 4 mars 2013130 8 oct. 2005 à 15:39
Mon dieu ! Utilise la fonction InStr pour détecter les espaces dans ta
phrase, et compte le nombre d'espace, ce sera bien plus simple que de
passer par autant de textbox que de mots (d'ailleurs, j'ai du mal à
comprendre l'intérêt d'atant de textbox !!!)
_____________________________________________________________________
DarK Sidious
Un API Viewer (pour le VB, VB.NET, C, C# et Delphi) tout en français : www.ProgOtoP.com/popapi/