Zdarec, potřeboval bych poradit.
Tady je naprogramováno, aby se vložilo 10 jmen a 10 časů, a poté je to seřadilo. Já potřebuji pomocí Do-Loop-While udělat, aby to nebylo jen pro 10, ale pro neomezeny počet. Zakončeno nulou. :
Sub Zavodnici()
Dim i As Byte
Dim Body As Integer, Jmeno As String
For i = 1 To 10
Cells(i, 1) = InputBox("Zadejte jméno " & i & ". žáka")
Cells(i, 2) = InputBox("Zadejte body " & i & ". žáka")
Next i
For i = 2 To 10
For j = 10 To i Step -1
If Cells(j, 2) > Cells(j - 1, 2) Then
Body = Cells(j - 1, 2)
Cells(j - 1, 2) = Cells(j, 2)
Cells(j, 2) = Body
Jmeno = Cells(j - 1, 1)
Cells(j - 1, 1) = Cells(j, 1)
Cells(j, 1) = Jmeno
End If
Next j
Next i
End Sub
Fórum › Visual Basic
Do-Loop-While

Založ si proměnnou pocet (integer), která bude na začátku 0. Místo for bude do (while). Inkrementuj pocet. Místo i bude v programu pocet (např. Cells(pocet, 1) apod.). Podmínka ve while bude Cells(pocet, 1) != 0. A cykly do třídění budou od 2 do pocet a od pocet do i. Pozor na datové typy použitých proměnných.
pocet = 0
Do
pocet = pocet + 1
Cells(pocet, 1) = InputBox("Zadejte jméno " & pocet & ". žáka")
Cells(pocet, 2) = InputBox("Zadejte body " & pocet & ". žáka")
Loop While (Cells(pocet, 1) <> "konec")
For i = 2 To pocet
For j = 1 To pocet Step -1
A pokud se ti nelíbí, že se ti i konec vloží do tabulky, tak jméno žáka ulož do stringu, který otestuj a ....

Přidej příspěvek
Toto téma je starší jak čtvrt roku – přidej svůj příspěvek jen tehdy, máš-li k tématu opravdu co říct!
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
Aktuálně jsou podporována videa ze serverů YouTube, Vimeo a Dailymotion.
×






























































Uživatelé prohlížející si toto vlákno
Uživatelé on-line: 0 registrovaných, 5 hostů
Podobná vlákna
Python for loop — založil Bius
Switch, case loop — založil Kefi
Infinite loop v OpenCL — založil Matus
Rozbor kodu, for loop — založil shockwave
Loop pro wordpress na homepage — založil Návštěvník
Moderátoři diskuze