⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.vb

📁 Mastering VBNet Include Source Code
💻 VB
字号:
Option Strict On
Public Class ColorsForm
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
    Friend WithEvents redBar As System.Windows.Forms.HScrollBar
    Friend WithEvents greenBar As System.Windows.Forms.HScrollBar
    Friend WithEvents blueBar As System.Windows.Forms.HScrollBar
    Friend WithEvents PictureBox2 As System.Windows.Forms.PictureBox

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.Container

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.greenBar = New System.Windows.Forms.HScrollBar()
        Me.PictureBox1 = New System.Windows.Forms.PictureBox()
        Me.PictureBox2 = New System.Windows.Forms.PictureBox()
        Me.redBar = New System.Windows.Forms.HScrollBar()
        Me.blueBar = New System.Windows.Forms.HScrollBar()
        Me.SuspendLayout()
        '
        'greenBar
        '
        Me.greenBar.Location = New System.Drawing.Point(0, 168)
        Me.greenBar.Maximum = 255
        Me.greenBar.Name = "greenBar"
        Me.greenBar.Size = New System.Drawing.Size(416, 16)
        Me.greenBar.TabIndex = 1
        Me.greenBar.Value = 128
        '
        'PictureBox1
        '
        Me.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.PictureBox1.Location = New System.Drawing.Point(8, 8)
        Me.PictureBox1.Name = "PictureBox1"
        Me.PictureBox1.Size = New System.Drawing.Size(192, 128)
        Me.PictureBox1.TabIndex = 3
        Me.PictureBox1.TabStop = False
        '
        'PictureBox2
        '
        Me.PictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.PictureBox2.Location = New System.Drawing.Point(224, 8)
        Me.PictureBox2.Name = "PictureBox2"
        Me.PictureBox2.Size = New System.Drawing.Size(192, 128)
        Me.PictureBox2.TabIndex = 3
        Me.PictureBox2.TabStop = False
        '
        'redBar
        '
        Me.redBar.Location = New System.Drawing.Point(0, 144)
        Me.redBar.Maximum = 255
        Me.redBar.Name = "redBar"
        Me.redBar.Size = New System.Drawing.Size(416, 16)
        Me.redBar.TabIndex = 0
        Me.redBar.Value = 128
        '
        'blueBar
        '
        Me.blueBar.Location = New System.Drawing.Point(0, 192)
        Me.blueBar.Maximum = 255
        Me.blueBar.Name = "blueBar"
        Me.blueBar.Size = New System.Drawing.Size(416, 16)
        Me.blueBar.TabIndex = 2
        Me.blueBar.Value = 128
        '
        'ColorsForm
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(424, 213)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.PictureBox2, Me.PictureBox1, Me.blueBar, Me.greenBar, Me.redBar})
        Me.Name = "ColorsForm"
        Me.Text = "Colors"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub redBar_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles redBar.Scroll
        If e.Type = ScrollEventType.EndScroll Then ColorBox1()
    End Sub

    Private Sub greenBar_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles greenBar.Scroll
        If e.Type = ScrollEventType.EndScroll Then ColorBox1()
    End Sub

    Private Sub blueBar_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles blueBar.Scroll
        If e.Type = ScrollEventType.EndScroll Then ColorBox1()
    End Sub

    Private Sub redBar_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles redBar.ValueChanged
        ColorBox2()
    End Sub

    Private Sub greenBar_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles greenBar.ValueChanged
        ColorBox2()
    End Sub

    Private Sub blueBar_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles blueBar.ValueChanged
        ColorBox2()
    End Sub

    Sub ColorBox1()
        Dim clr As Color
        clr = Color.FromArgb(redBar.Value, greenBar.Value, blueBar.Value)
        PictureBox1.BackColor = clr
    End Sub

    Sub ColorBox2()
        Dim clr As Color
        clr = Color.FromArgb(redBar.Value, greenBar.Value, blueBar.Value)
        PictureBox2.BackColor = clr
    End Sub

End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -