Kayıt
17 Kasım 2007
Mesajlar
10.379
Beğeniler
2
Şehir
istanbul / bomonti
Formumuza 3 tane textbox ve 1 tane combobox,3 tane label ve 2 tanede buton ekliyoruz.Label'ın birine 1.sayı diğerine 2.sayı ve üçüncüsünede işlem yazıyoruz.1. sayı yazan textbox1'in üst kısmına 2.sayı yazantextbox2'nin üst kısmına diğerini de combobox'ın üst kısmına yerleştiriyoruz. 1.Butona hesapla 2.butonada temizle yazıyoruz.
Kod:
Public Class Form1
    Dim sayi, sayi1 As Double

    Public Class Form1
    Dim sayi, sayi1 As Double
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        sayi = Val(TextBox1.Text)
        sayi1 = Val(TextBox2.Text)
        If ComboBox1.Text = "+" Then
            TextBox3.Text = sayi + sayi1
        End If
        If ComboBox1.Text = "-" Then
            TextBox3.Text = sayi - sayi1
        End If
        If ComboBox1.Text = "*" Then
            TextBox3.Text = sayi * sayi1
        End If
        If ComboBox1.Text = "/" Then
            TextBox3.Text = sayi / sayi1
        End If
        If ComboBox1.Text = "" Then
            MessageBox.Show("Lütfen yapacağınız işlemi seçiniz", "UYARI")
        End If
        If TextBox1.Text = "" Then
            MessageBox.Show("Lütfen birinci sayıyı giriniz...", "UYARI")
        End If
        If TextBox2.Text = "" Then
            MessageBox.Show("Lütfen ikinci sayıyı giriniz...", "UYARI")
        End If
    End Sub

    Private Sub Form1_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("/")
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Clear()
        TextBox2.Clear()
        TextBox3.Clear()
        ComboBox1.Text = ""
    End Sub
End Class
 
Yukarı Alt