Outils logiciels pour les cours Paris II
Cours Paris II
Stages/ Thèses/ Séminaires |
Cours 6Formulaires Les formulaires permettent de construire des interfaces efficaces pour interagir avec les programmes. Dans l’Editeur : Insertion-> UserForm
Sub Macro1() UserForm1.Show End Sub
Private Sub CommandButton1_Click() Range("B1").Value = 2 * Cells(1, 1) End Sub Private Sub CommandButton2_Click() ' Bouton QUITTER ' Masquer Userform1 UserForm1.Hide ' Récupérer la memoire occupée par userform1 Unload UserForm1 End Sub
Private Sub TextBox1_Change() Range("A1").Value = TextBox1.Value End Sub
Sub CommandButton1_Click() Dim myArray(15) As Double For I = 1 To 15 Step 1 myArray(I) = Cells(I, 1) Next Call QSort(myArray, 0, Cells(1,2)) For I = 1 To 15 Step 1 Cells(I, 6) = myArray(I) Next End Sub Sub QSort(sortArray() As Double, ByVal leftIndex As Integer, _ ByVal rightIndex As Integer) Dim compValue As Double Dim I As Integer Dim J As Integer Dim tempNum As Double I = leftIndex J = rightIndex compValue = sortArray(Int((I + J) / 2)) Do Do While (sortArray(I) < compValue And I < rightIndex) I = I + 1 Loop Do While (compValue < sortArray(J) And J > leftIndex) J = J - 1 Loop If I <= J Then tempNum = sortArray(I) sortArray(I) = sortArray(J) sortArray(J) = tempNum I = I + 1 J = J - 1 End If Loop While I <= J If leftIndex < J Then QSort sortArray(), leftIndex, J If I < rightIndex Then QSort sortArray(), I, rightIndex End Sub
Rnd() renvoie une valeur réelle, uniforme entre 0 et 1. Trouver une distribution uniforme sur les valeurs {1,2,3,4} L = CInt((Rnd * 4) + 0.5) |