VB語言基礎重要知識點20(滾動條應用)

  • 2020 年 1 月 23 日
  • 筆記

滾動條控制項:水平滾動條和垂直滾動條

如何配置滾動條值的範圍?

配置最大值:使用max屬性

配置最小值:使用min屬性

如何獲取滾動條當前的這個位置的值?

使用value屬性

滾動條的Change事件:是指當滾動條的當前的值發生變化,就會執行的事件。

如何讓窗體載入的出來的時候,就呈現滾動條設置好的顏色呢?

Form_Load事件進行載入

注意:VB中的所有的控制項的屬性基本上既可以進行設置又可以進行獲取。

本節知識效果圖:

本節知識源程式碼:

Dim s As String  Private Sub Command1_Click()MsgBox VScroll1.ValueEnd Sub  Private Sub Form_Load()s = "向下"lblred.Caption = VScroll1.Valuelblgreen.Caption = VScroll2.Valuelblblue.Caption = VScroll3.Value  Form1.BackColor = RGB(VScroll1.Value, VScroll2.Value, VScroll3.Value)End Sub  Private Sub Timer1_Timer()  If Command1.Top <= 0 Then    s = "向下"End If  If Command1.Top >= 5040 Then    s = "向上"End If    If s = "向下" Then    Command1.Top = Command1.Top + 10End If  If s = "向上" Then    Command1.Top = Command1.Top - 10End If    End Sub  Private Sub VScroll1_Change()lblred.Caption = VScroll1.ValueForm1.BackColor = RGB(VScroll1.Value, VScroll2.Value, VScroll3.Value)  End Sub  Private Sub VScroll2_Change()lblgreen.Caption = VScroll2.ValueForm1.BackColor = RGB(VScroll1.Value, VScroll2.Value, VScroll3.Value)End Sub  Private Sub VScroll3_Change()lblblue.Caption = VScroll3.ValueForm1.BackColor = RGB(VScroll1.Value, VScroll2.Value, VScroll3.Value)End Sub

相關文章:

  1. VB語言基礎重要知識點01
  2. VB語言基礎重要知識點02
  3. VB語言基礎重要知識點03
  4. VB語言基礎重要知識點04
  5. VB語言基礎重要知識點05
  6. VB語言基礎重要知識點06
  7. VB語言基礎重要知識點07
  8. VB語言基礎重要知識點08
  9. VB語言基礎重要知識點09
  10. VB語言基礎重要知識點10
  11. VB語言基礎重要知識點11
  12. VB語言基礎重要知識點12
  13. VB語言基礎重要知識點13
  14. VB語言基礎重要知識點14
  15. VB語言基礎重要知識點15
  16. VB語言基礎重要知識點16
  17. VB語言基礎重要知識點17
  18. VB語言基礎重要知識點18