1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
Option Compare Text
Private Sub Form_Load()
Dim TableauGénéral As Variant
Dim France, Espagne, Allemagne, Angleterre, EADS, Chine, AmeriqueNord As Variant
Dim TabGen As Variant
MonMot = InputBox("Saisi d'un mot")
'Je défini pour chaque pays les mots clefs qui correspondent
France = Array("Fra", "france", "fr", "toulouse", "paris")
Espagne = Array("spain", "espana", "españa", "madrid", "seville")
Allemagne = Array("Allemagne", "germany", "deutschland", "ger", "hambourg", "hamburg")
Angleterre = Array("angleterre", "u.k.", "uk")
EADS = Array("eads")
Chine = Array("chine", "china", "pekin", "beijing", "asia")
AmeriqueNord = Array("amerique du nord", "washington", "washington D.C.", "washington dc", "New York")
'Je définis un tableau général avec la liste des tableaux ci-dessus
TableauGénéral = Array(France, Espagne, Allemagne, Angleterre, EADS, Chine, AmeriqueNord)
'Pour chaque éléments du tableau général
For Index = 0 To UBound(TableauGénéral)
'Je récupère la valeur de l'index
TabGen = TableauGénéral(Index)
'Boucle imbriquée ou je lis tous les mots clefs du sous-tableau
For Index2 = 0 To UBound(TabGen)
'Je récupère le mot clef en cours
MotClef = TabGen(Index2)
'Si ce mot clef correspond à MonMot
If MotClef = MonMot Then
'Je récupère le nom du pays concerné
Select Case Index
Case "0": NomPays = "France"
Case 1: NomPays = "Espagne"
Case "2": NomPays = "Allemagne"
Case "3": NomPays = "Angleterre"
Case "4": NomPays = "EADS"
Case "5": NomPays = "Chine"
Case "6": NomPays = "Amérique du Nord"
End Select
MsgBox "Nom du pays: " & NomPays
Exit Sub
End If
Next
Next
End Sub |
Partager