計算機程式碼


 



 


Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

 



 


        T1.ForeColor = Color.FromArgb(255, 0, 0)

 



 


        T2.ForeColor = Color.FromArgb(0, 0, 255)

 



 


        T1.Font = New Font("標楷體", 14, FontStyle.Bold Or FontStyle.Italic)

 



 


        T2.Font = New Font("標楷體", 14, FontStyle.Bold Or FontStyle.Italic)

 



 


        L1.Font = New Font("標楷體", 14, FontStyle.Bold Or FontStyle.Italic)

 



 


        L2.Font = New Font("標楷體", 14, FontStyle.Bold Or FontStyle.Italic)

 



 


        L3.Font = New Font("標楷體", 14, FontStyle.Bold Or FontStyle.Italic)

 



 


    End Sub

 



    Private Sub B1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles B1.Click

 



 


        Dim f As Double

 



 


        f = CInt(T1.Text) + T2.Text

 



 


        L3.Text = f

 



 


    End Sub

 



 


    Private Sub B2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles B2.Click

 



 


        Dim f As Double

 



 


        f = CInt(T1.Text) - T2.Text

 



 


        L3.Text = f

 



 


    End Sub

 



 


    Private Sub B3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles B3.Click

 



 


        Dim f As Double

 



 


        f = CInt(T1.Text) * T2.Text

 



 


        L3.Text = f

 



 


    End Sub

 



 


    Private Sub B4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles B4.Click

 



 


        Dim f As Double

 



 


        f = CInt(T1.Text) / T2.Text

 



 


        L3.Text = f

 



 


    End Sub

 



 


Private Sub B5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B5.Click

 



 


        Dim ret

 



 


        ret = MsgBox("確定離開嗎", MsgBoxStyle.OKCancel + MsgBoxStyle.Question + MsgBoxStyle.DefaultButton1)

 



 


        If ret = MsgBoxResult.OK Then End

 



 


    End Sub

 



 


    Private Sub T2_KeyPress1(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles T2.KeyPress

 



 


        If e.KeyChar = Chr(13) Then

 



 


            Dim f As Double

 



 


            f = CInt(T1.Text) + T2.Text

 



 


            L3.Text = f

 



 


        End If

 



 


    End Sub

 



 


Private Sub T1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.Key

 



 


PressEventArgs) Handles T1.KeyPress

 



 


        If e.KeyChar = Chr(13) Then

 



 


            T2.Focus()

 



 


        End If

 



 


    End Sub

 



 


End Class

 



 

arrow
arrow
    全站熱搜

    allnewtim 發表在 痞客邦 留言(0) 人氣()