Exercices de programmation avec le langage VB

Exercice VB: Media Player

Ecrire le programme qui permet de réaliser l'interface suivante:

Remarque: la boutton Player = Ouvrire un nouveau fichier contenant des médiats

ExerciceVB-id2083 

Solution :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdplay.Click

        OpenFileDialog1.ShowDialog()

        Player.URL = OpenFileDialog1.FileName
    End Sub

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        End
    End Sub

    Private Sub Media_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs)
        'Dim pt As Point = Label2.Location
        'pt.Offset(0, Label2.Height)
        'Stagiaires.Show(Me, pt)
    End Sub

End Class

Exercice VB: Examen de Visual Basic 2ème session

Enonc-exerciceVB-2089

Solution :

Corrig-exerciceVB-2089

Exercice Visual Basic : ListBox

Ecrire le code VB qui permet de réaliser l'interface suivante:

ExerciceVB-id2130
Solution :

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
Public Class Form1


    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        TextBox3.Text = ListBox1.Items.Count
        TextBox4.Text = ListBox1.SelectedIndex
        TextBox5.Text = ListBox1.Text
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        ListBox1.Items.Clear()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ListBox1.Items.Add(TextBox1.Text)
        TextBox1.Text = ""
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Val(TextBox2.Text) <= ListBox1.Items.Count - 1 Then
            ListBox1.SelectedIndex = CInt(TextBox2.Text)
        Else
            MsgBox("L'élément rechercher est introuvable!")
        End If

    End Sub
End Class


Exercice Visual Basic : Editer Facture

ExerciceVB-id2120

Solution :

CorrigVB-id2120