2019年4月10日 星期三

自由軟體

自由軟體
1、使用的自由
2、研究的自由
3、修改的自由
4、散佈的自由

自由軟體←開放原始碼
自由軟體←有沒有版權?GPL
自由Free  ≠  免費Free

數位邏輯

數位邏輯

A
B
A XOR B
0
0
0
0
1
1
1
0
1
1
1
0

A
B
A XNOR B
0
0
1
0
1
0
1
0
0
1
1
1

A
B
A AND B
0
0
0
0
1
0
1
0
0
1
1
1

A
B
A OR B
0
0
0
0
1
1
1
0
1
1
1
1

A
NOT A
0
1
1
0

2019年4月9日 星期二

結構化程式設計

結構化程式設計:
        A、每個流程都是→單向流程。
        B、每個結構都是單一入口、單一出口。

一、循序結構。
  1→2→3→……

二、選擇結構。
  If 條件式一 Then
    條件一符合時,執行本段程式
  ElseIf 條件式二 Then
    條件二符合時,執行本段程式
  Else
    以上條件都不符合時,執行本段程式
  EndIf

三、重複結構。
  前測While
    Do While 條件
       條件符合時,執行本段程式
    Loop

  前測Until
    Do Until 條件
       條件不符合時,執行本段程式
    Loop

  后測While
    Do
       執行本段程式
    Loop While 條件

  后測Until
    Do
       執行本段程式
    Loop Until 條件

  For X=1 to N Step
    執行本段程式
  Next X

Hello



Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label1.Text = Button1.Text + ",  " + TextBox1.Text
    End Sub

End Class

平均值



Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = (Val(TextBox2.Text) + Val(TextBox3.Text)) / 2
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
    End Sub

End Class

調色盤ColorV7



Public Class Form1
    Dim R As Integer
    Dim G As Integer
    Dim B As Integer
    Dim A As Integer
    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        R = TrackBar1.Value
        G = TrackBar2.Value
        B = TrackBar3.Value
        Call SetColor(R, G, B)
    End Sub

    Private Sub TrackBar2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar2.Scroll
        R = TrackBar1.Value
        G = TrackBar2.Value
        B = TrackBar3.Value
        Call SetColor(R, G, B)
    End Sub

    Private Sub TrackBar3_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar3.Scroll
        R = TrackBar1.Value
        G = TrackBar2.Value
        B = TrackBar3.Value
        Call SetColor(R, G, B)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        R = val(InputBox("請輸入紅色", "紅", 128))
        G = val(InputBox("請輸入綠色", "綠", 128))
        B = val(InputBox("請輸入藍色", "藍", 128))
        Call SetColor(R, G, B)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        R = Val(TextBox1.Text)
        G = Val(TextBox2.Text)
        B = Val(TextBox3.Text)
        Call SetColor(R, G, B)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        R = TrackBar1.Value
        G = TrackBar2.Value
        B = TrackBar3.Value
        A = MsgBox("您的色彩有" + "  紅色=" & R & "  綠色=" & G & "  藍色=" & B, MsgBoxStyle.YesNo + MsgBoxStyle.Information, "調色盤")
    End Sub
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        R = TrackBar1.Value + 10
        Call SetR(R)
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        R = TrackBar1.Value + 1
        Call SetR(R)
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        R = TrackBar1.Value - 1
        Call SetR(R)
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        R = TrackBar1.Value - 10
        Call SetR(R)
    End Sub


    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        G = TrackBar2.Value + 10
        Call SetG(G)
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        G = TrackBar2.Value + 1
        Call SetG(G)
    End Sub

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        G = TrackBar2.Value - 1
        Call SetG(G)
    End Sub

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        G = TrackBar2.Value - 10
        Call SetG(G)
    End Sub

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        B = TrackBar3.Value + 10
        Call SetB(B)
    End Sub

    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        B = TrackBar3.Value + 1
        Call SetB(B)
    End Sub

    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
        B = TrackBar3.Value - 1
        Call SetB(B)
    End Sub

    Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
        B = TrackBar3.Value - 10
        Call SetB(B)
    End Sub

    Sub SetR(ByRef R As Integer)
        If R > 255 Then
            R = 255
        ElseIf R < 0 Then
            R = 0
        End If
        G = TrackBar2.Value
        B = TrackBar3.Value
        Call SetColor(R, G, B)
    End Sub

    Sub SetG(ByRef G As Integer)
        R = TrackBar1.Value
        If G > 255 Then
            G = 255
        ElseIf G < 0 Then
            G = 0
        End If
        B = TrackBar3.Value
        Call SetColor(R, G, B)
    End Sub

    Sub SetB(ByRef B As Integer)
        R = TrackBar1.Value
        G = TrackBar2.Value
        If B > 255 Then
            B = 255
        ElseIf B < 0 Then
            B = 0
        End If
        Call SetColor(R, G, B)
    End Sub

    Sub SetColor(ByRef R As Integer, ByRef G As Integer, ByRef B As Integer)
        TrackBar1.Value = R
        TrackBar2.Value = G
        TrackBar3.Value = B

        Label1.Text = R

        Label2.Text = G
        Label3.Text = B

        TextBox1.Text = R

        TextBox2.Text = G
        TextBox3.Text = B

        PictureBox1.BackColor = Color.FromArgb(R, 0, 0)

        PictureBox2.BackColor = Color.FromArgb(0, G, 0)
        PictureBox3.BackColor = Color.FromArgb(0, 0, B)

        PictureBox4.BackColor = Color.FromArgb(R, G, B)

    End Sub

End Class

調色盤ColorV6



Public Class Form1

    Dim R As Integer
    Dim G As Integer
    Dim B As Integer
    Dim A As Integer

    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        R = TrackBar1.Value
        G = TrackBar2.Value
        B = TrackBar3.Value
        Call SetColor(R, G, B)
    End Sub

    Private Sub TrackBar2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar2.Scroll
        R = TrackBar1.Value
        G = TrackBar2.Value
        B = TrackBar3.Value
        Call SetColor(R, G, B)
    End Sub

    Private Sub TrackBar3_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar3.Scroll
        R = TrackBar1.Value
        G = TrackBar2.Value
        B = TrackBar3.Value
        Call SetColor(R, G, B)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        R = val(InputBox("請輸入紅色", "紅", 128))
        G = val(InputBox("請輸入綠色", "綠", 128))
        B = val(InputBox("請輸入藍色", "藍", 128))
        Call SetColor(R, G, B)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        R = Val(TextBox1.Text)
        G = Val(TextBox2.Text)
        B = Val(TextBox3.Text)
        Call SetColor(R, G, B)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        R = TrackBar1.Value
        G = TrackBar2.Value
        B = TrackBar3.Value
        A = MsgBox("您的色彩有" + "  紅色=" & R & "  綠色=" & G & "  藍色=" & B, MsgBoxStyle.YesNo + MsgBoxStyle.Information, "調色盤")
    End Sub

    Sub SetColor(ByRef R As Integer, ByRef G As Integer, ByRef B As Integer)
        TrackBar1.Value = R
        TrackBar2.Value = G
        TrackBar3.Value = B

        Label1.Text = R

        Label2.Text = G
        Label3.Text = B

        TextBox1.Text = R

        TextBox2.Text = G
        TextBox3.Text = B

        PictureBox1.BackColor = Color.FromArgb(R, 0, 0)

        PictureBox2.BackColor = Color.FromArgb(0, G, 0)
        PictureBox3.BackColor = Color.FromArgb(0, 0, B)

        PictureBox4.BackColor = Color.FromArgb(R, G, B)

    End Sub

End Class