Скачать презентацию Массивы Dim Arr_Name Max_Elements_Index As Elemets_Type Dim City 2 As Скачать презентацию Массивы Dim Arr_Name Max_Elements_Index As Elemets_Type Dim City 2 As

Массивы.pptx

  • Количество слайдов: 10

Массивы Dim Arr_Name(Max_Elements_Index) As Elemets_Type Dim City(2) As String City(0) = “Ростов” : City(1) Массивы Dim Arr_Name(Max_Elements_Index) As Elemets_Type Dim City(2) As String City(0) = “Ростов” : City(1) = “Москва” : Cite(2) = “Таганрог” Dim City() As String = {“Ростов”, “Москва” , “Таганрог”} Многомерные массивы Dim arr(2, 3) As Integer arr(0, 0) = 100; Динамические массивы Dim dynam_Arr() As String

Динамические массивы Dim int. Array() As Integer Re. Dim int. Array(1) int. Array(0) = Динамические массивы Dim int. Array() As Integer Re. Dim int. Array(1) int. Array(0) = 1 Нельзя изменять размерность массива! int. Array(1) = 2 Re. Dim int. Array(1, 2) int. Array(2) = 3 Re. Dim int. Array(2) = 3 0, 0, 3 Re. Dim Preserve int. Array(2)=3 1, 2, 3 Re. Dim int. Array(1) 0, 0 Re. Dim Preserve int. Array(1) 1, 2 В многомерных массивах с использование Preserve можно изменять размер только последнего измерения ! Dim arr(2, 3) As Integer … Re. Dim arr(4, 5) Re. Dim Preserve arr(5, 5) ошибка Re. Dim Preserve arr(4, 3) Очистка памяти Erase arr 1, arr 2, arr 3

Определение размера массива Dim arr(10) As String Dim n As Integer n=arr. Length Public Определение размера массива Dim arr(10) As String Dim n As Integer n=arr. Length Public Function UBound( By. Val Array As System. Array, _ Optional By. Val Rank As Integer = 1 ) As Integer Dim highest, multy. Arr(10, 15, 20), mono. Arr(6) As Integer highest = Ubound(multy. Arr, 1) ‘ 10 highest = Ubound(multy. Arr, 3) ‘ 20 highest = UBound(mono. Arr) ‘ 6 Dim a(100, 5, 4) As Byte Dim total As Integer total = (UBound(A, 1) + 1) * (UBound(A, 2) + 1) * (UBound(A, 3) + 1)

Mouse Event Private Sub Picture. Box 1_Mouse(By. Val sender As Object, _ By. Val Mouse Event Private Sub Picture. Box 1_Mouse(By. Val sender As Object, _ By. Val e As System. Windows. Forms. Mouse. Event. Args) _ Handles Picture. Box 1. Mouse. Down, Picture. Box 1. Mouse. Click, _ Picture. Box 1. Mouse. Up, Picture. Box 1. Mouse. Move Private Sub Picture. Box 1_Mouse. Enter(By. Val sender As Object, _ By. Val e As System. Event. Args) Handles Picture. Box 1. Mouse. Enter, _ Picture. Box 1. Mouse. Leave, Picture. Box 1. Mouse. Hover 1. Mouse. Down 2. Click 3. Mouse. Click 4. Mouse. Up If sender. Get. Type. Name = "Picture. Box" Then … If sender. Name = "Picture. Box 1" Then … Msg. Box(“e. X=“ & e. X & “ e. Y=“ & e. Y) Picture. Box 1. Location=e. Location

Picture. Box - Size. Mode Normal Center. Image Auto. Size Zoom Stretch. Image Picture. Box - Size. Mode Normal Center. Image Auto. Size Zoom Stretch. Image

Положение объекта Left, Right, Top, Bottom, Location Private Sub Form 1_Mouse. Click(By. Val sender Положение объекта Left, Right, Top, Bottom, Location Private Sub Form 1_Mouse. Click(By. Val sender As Object, _ By. Val e As System. Windows. Forms. Mouse. Event. Args) _ Handles Me. Mouse. Click 'Pic. Cat. Left = e. X ' Pic. Cat. Top = e. Y Pic. Cat. Location = e. Location End Sub Private Sub Picture. Box 1_Mouse. Click(By. Val sender As Object, _ By. Val e As System. Windows. Forms. Mouse. Event. Args) _ Handles Pic. Cat. Mouse. Click Pic. Cat. Location = e. Location Dim p As Point Pic. Cat. Left += e. X p. X = Pic. Cat. Location. X + e. X Pic. Cat. Top += e. Y End Sub p. Y = Pic. Cat. Location. Y + e. Y Pic. Cat. Location = p End Sub

Перемещение объекта Dim Mouse. Location As Point Dim Cat. Move As Boolean Private Sub Перемещение объекта Dim Mouse. Location As Point Dim Cat. Move As Boolean Private Sub Pic. Cat_Mouse. Down(…) Handles Pic. Cat. Mouse. Down Cat. Move = True Mouse. Location = e. Location End Sub Private Sub Pic. Cat_Mouse. Move(…) Handles Pic. Cat. Mouse. Move Dim d. X, d. Y As Integer If Cat. Move Then d. X = e. X - Mouse. Location. X d. Y = e. Y - Mouse. Location. Y Pic. Cat. Left+ = d. X Pic. Cat. Top += d. Y End If End Sub Private Sub Pic. Cat_Mouse. Up(…) Handles Pic. Cat. Mouse. Up Cat. Move = False End Sub

Динамическая загрузка изображения Picture. Box 1. Load(Path. String) Dim Pic. Array() As String = Динамическая загрузка изображения Picture. Box 1. Load(Path. String) Dim Pic. Array() As String = {"cat. gif", "cat 1. gif", "cat 2. gif"} Dim Cat. Index As Integer=0 Private Sub btn. Cat_Click(By. Val sender As System. Object, By. Val e As System. Event. Args)_ Handles btn. Cat. Click Cat. Index += 1 Cat. Index = Cat. Index Mod 3 Picture. Box 1. Load(Pic. Array(Cat. Index)) ‘Picture. Box 1. Load("D: VBLab 5cat 2. gif") End Sub Private Sub Button. Cursor_Click(By. Val sender As System. Object, By. Val e As System. Event. Args) Handles Button. Cursor. Click Static face. Count As Integer = 0 Dim cur. Name As String face. Count += 1 face. Count = (face. Count Mod 5) + 1 cur. Name = "face 0" & face. Count & ". ico" Picture. Box 1. Cursor = New System. Windows. Forms. Cursor(cur. Name) End Sub

Определение нажатой клавиши мышки Select Case e. Button Case Mouse. Buttons. Left Msg. Box( Определение нажатой клавиши мышки Select Case e. Button Case Mouse. Buttons. Left Msg. Box("Левая кнопка") Case Mouse. Buttons. Right Msg. Box("Правая кнопка") Case Mouse. Buttons. Middle Msg. Box("Средняя кнопка") Case Mouse. Buttons. None Msg. Box("Кнопка не нажата") End Select

 Dim W, H As Integer Private Sub Picture. Box 1_Mouse. Down(…) Handles Picture. Dim W, H As Integer Private Sub Picture. Box 1_Mouse. Down(…) Handles Picture. Box 1. Mouse. Down W = Picture. Box 1. Width H = Picture. Box 1. Height Select Case e. Button Case Mouse. Buttons. Left Picture. Box 1. Height *= 2: Picture. Box 1. Width *= 2 Case Mouse. Buttons. Right Picture. Box 1. Height /= 2: Picture. Box 1. Width /= 2 End Select End Sub Private Sub Picture. Box 1_Mouse. Up(…) Handles Picture. Box 1. Mouse. Up Picture. Box 1. Width = W: Picture. Box 1. Height = H End Sub Private Sub Form 1_Load(…) Handles Me. Load Picture. Box 1. Size. Mode = Picture. Box. Size. Mode. Stretch. Image End Sub