Sub compteur()
Randomize()
cht1.Text = Int(Rnd(1) * 10)
(...)
Sub affichage()
Dim montableau(10) As UInteger
montableau(10) = cht1.Text
montableau(10) = cht2.Text
montableau(10) = cht3.Text
(....)
lalistbox.datasource = montableau()
with lalistbox .items.clear for i as integer =1 to 10 .items.add tableau(i) next i end with
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Function fct_chiffre(ByVal pvaleur As Integer) As String
Dim wchemin As String
fct_chiffre = wchemin
If pvaleur = 1 Then
wchemin = 1
(...)
Function fct_chiffre(ByVal pvaleur As Integer) As String if (pvaleur >0) and (pvaleur <11) then return pvaleur.tostring return string.empty end function
Sub compteur()
Randomize()
cht1.Text = Int(Rnd(1) * 10)
wresult cht1.Text fct_chiffre(cht1.Text)
cht2.Text = Int(Rnd(1) * 10)
wresult cht2.Text fct_chiffre(cht2.Text)
(...)
Dim montableau(10)
montableau(1) = cht1.Text
'chListBox1.Text = cht1.Text
montableau(2) = cht2.Text
'chListBox1.Text = cht2.Text
(...)
Pour trier la liste
*Affectez à la propriété Sorted la valeur true.
Ce paramètre repositionne tous les éléments de liste existants dans l'ordre de tri.
Public Class Form1 Function fct_chiffre(ByVal pvaleur As Integer) As String If (pvaleur > 0) And (pvaleur < 11) Then Return pvaleur.ToString Return String.Empty End Function Sub compteur() Randomize() cht1.Text = Int(Rnd(1) * 10) cht2.Text = Int(Rnd(1) * 10) cht3.Text = Int(Rnd(1) * 10) cht4.Text = Int(Rnd(1) * 10) cht5.Text = Int(Rnd(1) * 10) cht6.Text = Int(Rnd(1) * 10) cht7.Text = Int(Rnd(1) * 10) cht8.Text = Int(Rnd(1) * 10) cht9.Text = Int(Rnd(1) * 10) cht10.Text = Int(Rnd(1) * 10) End Sub Sub affichage() Dim montableau(10) As UInteger montableau(10) = cht1.Text montableau(10) = cht2.Text montableau(10) = cht3.Text montableau(10) = cht4.Text montableau(10) = cht5.Text montableau(10) = cht6.Text montableau(10) = cht7.Text montableau(10) = cht8.Text montableau(10) = cht9.Text montableau(10) = cht10.Text End Sub Private Sub bt_go_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bt_go.Click Call compteur() End Sub Private Sub bt_affichage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bt_affichage.Click Call affichage() End Sub End Class
Public Class Form1 Function fct_chiffre(ByVal pvaleur As Integer) As String If (pvaleur > 0) And (pvaleur < 11) Then Return pvaleur.ToString Return String.Empty End Function Sub compteur() Randomize() cht1.Text = Int(Rnd(1) * 10) cht2.Text = Int(Rnd(1) * 10) cht3.Text = Int(Rnd(1) * 10) cht4.Text = Int(Rnd(1) * 10) cht5.Text = Int(Rnd(1) * 10) cht6.Text = Int(Rnd(1) * 10) cht7.Text = Int(Rnd(1) * 10) cht8.Text = Int(Rnd(1) * 10) cht9.Text = Int(Rnd(1) * 10) cht10.Text = Int(Rnd(1) * 10) End Sub Sub affichage() Dim montableau(10) As String Dim wcpt, wcptelement, wvaleur, wtempo As Integer montableau(1) = cht1.Text montableau(2) = cht2.Text montableau(3) = cht3.Text montableau(4) = cht4.Text montableau(5) = cht5.Text montableau(6) = cht6.Text montableau(7) = cht7.Text montableau(8) = cht8.Text montableau(9) = cht9.Text montableau(10) = cht10.Text For wcptelement = 1 To 10 wvaleur = montableau(wcptelement) For wcpt = (wcptelement + 1) To 10 If wvaleur > montableau(wcpt) Then wtempo = montableau(wcpt) montableau(wcpt) = wvaleur wvaleur = wtempo End If Next wcpt chListBox1.Items.Add(wvaleur) Next wcptelement End Sub Private Sub bt_go_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bt_go.Click Call compteur() End Sub Private Sub bt_affichage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bt_affichage.Click Call affichage() End Sub End Class
Private Sub SetRandomBoxes() 'random + affichage Dim rd As New Random For i As Integer = 1 To 10 Me.Controls("cht" & i.ToString).Text = rd.Next(0, 9).ToString Next rd = Nothing End Sub Private Sub ShowSortedBoxes() 'récup en tableau Dim lsValues As New System.Collections.Generic.List(Of String) For i As Integer = 1 To 10 lsValues.Add(Me.Controls("cht" & i.ToString).Text) Next 'tri, affichage lsValues.Sort() chListBox1.DataSource = lsValues lsValues.Clear() End Sub