Afin de réaliser ces programmes,
vous pouvez télécharger ici les fichiers utilisés (à extraire dans « C:\ »)

PROGRAMME 1 : Sub Concordance

Sub concordance()
'
' concordance Macro
' Macro créée le 25/05/2006 par Charlène Dufier
'
forme$ = InputBox$("Entrez un mot", "concordance")
choix$ = InputBox$("Tapez 1 pour rtf ou 2 pour html")

If choix$ = "1" Then
debut$ = "{\rtf1\ansi "
fin$ = "}"
grasdeb$ = "{\b "
grasfin$ = "}"
souldeb$ = "{\ul "
soulfin$ = "}"
italdeb$ = "{\i "
italfin$ = "}"
para$ = "{\par "

Open "C:/resu.rtf" For Output As 1

ElseIf choix$ = "2" Then
debut$ = "<html><head><title></title></head><body>"
fin$ = "</body></html>"
grasdeb$ = "<b>"
grasfin$ = "</b>"
souldeb$ = "<u>"
soulfin$ = "</u>"
italdeb$ = "<i>"
italfin$ = "</i>"
para$ = "<br>"

Open "c:/resu.htm" For Output As 1

End If

Print #1, debut$ + para$
Open "c:/duchn.txt" For Input As 2
comptforme = 0
comptligne = 0
While (EOF(2) = 0)
Line Input #2, ligne$
comptligne = comptligne + 1
k = InStr(ligne$, forme$)
If k > 0 Then
comptforme = comptforme + 1
gch$ = Left$(ligne$, k - 1)
ln = Len(forme$)
drt$ = Mid$(ligne$, k + ln)
Print #1, souldeb$ + "ligne n° " + Str$(comptligne) + ":" + soulfin$ + para$
Print #1, italdeb$ + gch$ + italfin$ + grasdeb$ + forme$ + grasfin$ + italdeb$ + drt$ + italfin$ + para$
End If
Wend
Print #1, Str$(comptligne) + "lignes traitées." + para$
Print #1, Str$(comptforme) + "formes traitées." + para$
Print #1, fin$
Close (1)
Close (2)
msg1$ = Str(comptligne) + "lignes traitées."
msg2$ = Str(comptforme) + "formes traitées."
MsgBox (msg1$ + Chr$(10) + msg2$)
If choix$ = "1" Then
Open FileName = "C:/resu.rtf" For Output As 1


ElseIf choix$ = "2" Then
Open FileName = "C:/resu.htm" For Output As 2


End If

End Sub
 


Ce programme permet à l’utilisateur de recenser une forme donnée et de l’afficher, selon son souhait, soit en RTF soit en html, avec son contexte gauche et droit. A la fin du document résultat on pourra voir le nombre de lignes et de formes traitées.
Téléchargez ici le code.

cliquez sur l'image pour agrandir cette derniére.
Le programme a créé deux fichiers résultats, un au format rtf et un au format htm.

PROGRAMME 2 : Sub context
Sub context()
a$ = InputBox$(”Entrez une phrase”, “Contexte”, “Le chat est noir”)
b$ = InputBox$(”Entrez un mot”, “Contexte”, “est”)
k = InStr(a$, b$)
gch$ = Left$(a$, k - 1)
lg = Len(b$)
drt$ = Mid$(a$, k + lg)
MsgBox (”Le contexte gauche est : ” + gch$ + Chr$(10) + “Le contexte droit est : ” + drt$)
End Sub
Ce programme permet à l’utilisateur d’isoler un mot donné et de donner son contexte gauche et droit.

cliquez sur l'image pour agrandir cette derniére.

PROGRAMME 3 : Sub filtre
Sub filtre()
Open “C:/dh89.txt” For Input As 1
Open “C:/filtre.txt” For Output As 2
b$ = InputBox$(”Entrez une forme”, “Filtrage”, “homme”)
compteur = 0
While (EOF(1) = 0)
Line Input #1, a$
k = InStr(a$, b$)
If k > 0 Then
compteur = compteur + 1
Print #2, “occurrence “, compteur, a$
End If
Wend
If compteur = 0 Then
MsgBox$ (”le mot n’apparait pas dans le texte”)
Else
MsgBox$ (”le mot ” + b$ + “ a été trouvé ” + Str(compteur) + ” fois”)
End If
Close (1)
Close (2)
End Sub
Ce programme permet à l’utilisateur de compter le nombre de fois où apparaît un mot dans un texte.

cliquez sur l'image pour agrandir cette derniére.

PROGRAMME 4 : Sub compteligne
Sub compteligne()
Open “C:/dh89.txt” For Input As 1
compteur = 0
While (EOF(1) = 0)
Line Input #1, a$
compteur = compteur + 1
Wend
Close (1)
MsgBox (”Le fichier contient ” + Str(compteur) + ” lignes”)
End Sub
Ce programme permet à l’utilisateur de compter le nombre de lignes que contient un fichier. Saisie d’écran

cliquez sur l'image pour agrandir cette derniére.

PROGRAMME 5 : Sub conjugueur
Sub conjugueur()
Open “C:/verbe.txt” For Output As 1
vb$ = InputBox$(”entrez un verbe du 1er groupe”, “Conjugueur”, “émerger”)
Dim pp$(6)
pp$(1) = “je”
pp$(2) = “tu”
pp$(3) = “il / elle”
pp$(4) = “nous”
pp$(5) = “vous”
pp$(6) = “ils / elles”
Dim flex$(6)
flex$(1) = “e”
flex$(2) = “es”
flex$(3) = “e”
flex$(4) = “ons”
flex$(5) = “ez”
flex$(6) = “ent”
rad$ = Left$(vb$, Len(vb$) - 2)
k = InStr(”aeiouyé”, Left$(rad$, 1))
If k > 0 Then
pp$(1) = “j’”
End If
k2 = InStr(”g”, Right$(rad$, 1))
If k2 > 0 Then
flex$(4) = “eons”
End If
For i = 1 To 6
conj$ = pp$(i) + ” ” + rad$ + flex$(i)
Print #1, conj$
Next i
Close (1)
End Sub
Ce programme permet à l’utilisateur de conjuguer un verbe du premier groupe.

cliquez sur l'image pour agrandir cette derniére.