2019年5月28日 星期二

扶養比--程式碼示範



Public Class Form1
    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
        Call Raise()
    End Sub

    Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
        Call Raise()
    End Sub

    Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
        Call Raise()
    End Sub

    Sub Raise()
        Dim Raise As Single
        Dim r, g, b As Integer
        If Val(TextBox2.Text) <> 0 Then
            Raise = (Val(TextBox1.Text) + Val(TextBox3.Text)) / Val(TextBox2.Text)
            Label6.Text = Raise * 100 & "%"
            REM
            r = Int(Raise * 2 * 255)
            If r > 255 Then
                r = 255
            ElseIf r < 0 Then
                r = 0
            End If
            g = Int(255 / (Raise * 10))
            If g > 255 Then
                g = 255
            ElseIf r < 0 Then
                g = 0
            End If
        End If
        PictureBox1.BackColor = Color.FromArgb(r, g, 0)
    End Sub


End Class

沒有留言:

張貼留言