
'==============================================================
'Sur la forme,
'4 TextBox propriété Tag de 1 à 4
'6 PictureBox propriété Tag de 1 à 6
'==============================================================
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
InitPic()
InitText()
End Sub
Sub InitText()
Dim Ctl As Control
Dim Txt As TextBox
Static NbAlea As Integer
NbAlea += 1 : If NbAlea > 4 Then NbAlea = 1
For Each Ctl In Me.Controls 'boucle sur tout les contrôles de la forme
If TypeOf Ctl Is TextBox Then 'Vérifie que c'est un textbox
Txt = Ctl
If Txt.Tag = NbAlea Then
'S'il n'y a que des TextBox sur la form il n'est pas nécessaire
'de passer par une variable buffer
Txt.Text = "c'est le TextBox : " & Txt.Name
Txt.BackColor = Color.Fuchsia
Else
Txt.Text = ""
Txt.BackColor = Color.Empty
End If
End If
Next
End Sub
Sub InitPic()
Dim Pic As Control
Dim Img As PictureBox
Static NbAlea As Integer
NbAlea += 1 : If NbAlea > 6 Then NbAlea = 1
'S'il n'y a que des pictureBox sur la form il n'est pas nécessaire
'de passer par une variable buffer
For Each Pic In Me.Controls 'boucle sur tout les contrôles de la forme
If TypeOf Pic Is PictureBox Then
Img = Pic
If Pic.Tag = NbAlea Then
Img.BackColor = Color.Aquamarine
Img.BorderStyle = BorderStyle.Fixed3D
'Img.Image = System.Drawing.Bitmap.FromFile(My.Application.Info.DirectoryPath & "\bt" & NbAlea & ".bmp")
'Img.SizeMode = PictureBoxSizeMode.StretchImage
Else
Img.BackColor = Color.Chocolate
Img.BorderStyle = BorderStyle.FixedSingle
End If
End If
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
InitText()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
InitPic()
End Sub
End Class
Combien cela coûte-t-il au total ? Quelles aides apportent l'état et les acteurs du marché pour alléger cette charge non choisie ? Tous les détails sur Commentçamarche.net.