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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
' OBJETS : form1 + button1 + button2 = 3
Option Explicit On
Public Class Form1
Dim debut As Integer ' début pour chaque langue
Dim _t(300) As String ' tableau des langues
Dim nomFichier As String = "fLangues.txt" ' nom du fichier
Dim laLangue As String = "" ' f, a ou e (f par défaut)
Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' français ' on peut entrer le code en dur
_t(1) = "Changer la langue " ' bouton 1 français
_t(2) = "lancement programme" ' bouton 2
_t(3) = "Programme en Français" ' bandeau form1
_t(4) = "Lancement du programme, et caetera" ' texte msgbox bouton 2
' abglais
_t(101) = "Change the language" ' bouton 1 anglais
_t(102) = "Call the program " ' bouton 2
_t(103) = "Program in English" ' bandeau form1
_t(104) = "Call of program, et caetera" ' texte msgbox bouton 2
' espagnol
_t(201) = "Changia la lingua " ' bouton 1 espagnol
_t(202) = "Appela el progrmmo " ' bouton 2
_t(203) = "Programo espagnola" ' bandeau form1
_t(204) = "Appelo los programo, et caetera" ' texte msgbox bouton 2
Call litLangue()
Call afficheLangue()
End Sub
Sub litLangue()
Try ' le fichier par défaut = répertoire application \ bin \ debug (qui sera compilé = répertoire de l'exe)
' existant = lecture
Dim p As New System.IO.StreamReader(CStr(My.Application.Info.DirectoryPath & "\" & nomFichier))
laLangue = p.ReadLine() ' lit ligne 1
p.Close() ' ferme
Catch ex As Exception ' si erreur ferme (après dim p ...) = inexistant = création
laLangue = "f" ' français par défaut à la création
Call ecritLangue()
End Try
End Sub
Sub ecritLangue()
Dim p As New System.IO.StreamWriter(CStr(My.Application.Info.DirectoryPath & "\" & nomFichier))
p.WriteLine(laLangue) ' écrit
p.Close() ' ferme
End Sub
Sub afficheLangue()
Select Case laLangue ' selon la langue
Case "f" : debut = 1 ' fr
Case "a" : debut = 101 ' ang
Case "e" : debut = 201 ' esp
End Select
Button1.Text = _t(debut + 0)
Button2.Text = _t(debut + 1)
Me.Text = _t(debut + 2)
End Sub
Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim la As String ' changement de la langue
la = InputBox("Choisir la langue" & vbLf & "f = fr" & vbLf & "a = ang" & vbLf & "e = esp")
If Len(la) <> 1 Then Exit Sub ' abandon, erreur...
If la = "f" Or la = "a" Or la = "e" Then
If la = laLangue Then Exit Sub ' langue déjà affichée
laLangue = la
Call ecritLangue()
Call afficheLangue()
End If
End Sub
Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MsgBox(_t(debut + 3), vbInformation)
End Sub
End Class |
Partager