1 / 16

Složené proměnné - pole

Learn about the different types of variables, including static, public, private, and dim, as well as how to declare and reference arrays in Visual Basic. Also, discover how to sort arrays using the Bubblesort algorithm.

Download Presentation

Složené proměnné - pole

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Složené proměnné - pole

  2. Typy dat • Static - Statická proměnná dokud pro danou proceduru, zachovává si platnost. • Public - Ve všech modulech a procedurách zachovává si platnost i po skončení danné procedury. • Private - dostupné pro všechny procedury v daném modulu • Dim - dostupné pro jednu proceduru v daném modulu. Jen když tento modul běží. Nebo pro procedury v daném modulu. Záleží kde je deklarace uvedena.

  3. Jednoduché typy dat

  4. Příklad deklarace proměnné • DimModHodnotaLg As Long • Dim a As Integer, b As Integer

  5. Deklarace pole • Dim MojePole (9) As Boolean • Dim MojePole (0 To 9) As Boolean • Dim FakturyPole (2009 To 2011) As Double • DimListPole () As Double • DimMojePole(9, 9) As Integer • DimMojePole(0 To 9, 0 To 9) As Integer

  6. Odkazování na prvky pole • ListPole(i) = ....

  7. Příklad DimArr(5) Arr(0) = "Pondělí" Arr(1) = "Úterý" Arr(2) = "Středa" Arr(3) = "Čtvrtek" Arr(4) = "Pátek" ' Vypíšeme do dialogového okna. MsgBoxArr(0) & "-" & Arr(1) & "-" & Arr(2) & "-" & Arr(3) & "-" & Arr(4)

  8. Příklad For i = 1 to 20 p(i) = ActiveSheet.Cells(i,1).Value Next i For i=1 to 20 ActiveSheet.Cells(i,1).Value = p(i) Next i

  9. 35 12 77 101 5 42 Řazení podle velikosti - Bubblesort • Sorting takes an unordered collection and makes it an ordered one. 1 2 3 4 5 6 101 12 42 35 5 77 1 2 3 4 5 6

  10. "Bubbling Up" the Largest Element • Traverse a collection of elements • Move from the front to the end • “Bubble” the largest value to the end using pair-wise comparisons and swapping 1 2 3 4 5 6 101 12 42 35 5 77

  11. 42 77 "Bubbling Up" the Largest Element • Traverse a collection of elements • Move from the front to the end • “Bubble” the largest value to the end using pair-wise comparisons and swapping Swap 1 2 3 4 5 6 101 12 42 35 5 77

  12. 35 77 "Bubbling Up" the Largest Element • Traverse a collection of elements • Move from the front to the end • “Bubble” the largest value to the end using pair-wise comparisons and swapping 1 2 3 4 5 6 Swap 101 12 77 35 5 42

  13. 12 77 "Bubbling Up" the Largest Element • Traverse a collection of elements • Move from the front to the end • “Bubble” the largest value to the end using pair-wise comparisons and swapping 1 2 3 4 5 6 Swap 101 12 35 77 5 42

  14. "Bubbling Up" the Largest Element • Traverse a collection of elements • Move from the front to the end • “Bubble” the largest value to the end using pair-wise comparisons and swapping 1 2 3 4 5 6 101 77 35 12 5 42 No need to swap

  15. 5 101 "Bubbling Up" the Largest Element • Traverse a collection of elements • Move from the front to the end • “Bubble” the largest value to the end using pair-wise comparisons and swapping 1 2 3 4 5 6 Swap 101 77 35 12 5 42

  16. "Bubbling Up" the Largest Element • Traverse a collection of elements • Move from the front to the end • “Bubble” the largest value to the end using pair-wise comparisons and swapping 1 2 3 4 5 6 101 5 77 35 12 42 Largest value correctly placed

More Related