Senin, 08 November 2010

Textbox & Combobox




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

        ComboBox1.Items.Add("+")
        ComboBox1.Items.Add("-")
        ComboBox1.Items.Add("*")
        ComboBox1.Items.Add("/")
        ComboBox1.Items.Add("mod")
        ComboBox1.Items.Add("^")

End Sub


Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

        If ComboBox1.SelectedItem = "+" Then
            TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
        ElseIf ComboBox1.SelectedItem = "-" Then
            TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
        ElseIf ComboBox1.SelectedItem = "*" Then
            TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
        ElseIf ComboBox1.SelectedItem = "/" Then
            TextBox3.Text = Val(TextBox1.Text) / Val(TextBox2.Text)
        ElseIf ComboBox1.SelectedItem = "mod" Then
            TextBox3.Text = Val(TextBox1.Text) Mod Val(TextBox2.Text)
        Else
            TextBox3.Text = Val(TextBox1.Text) ^ Val(TextBox2.Text)
        End If

End Sub



Tidak ada komentar:

Posting Komentar