Kayıt
17 Kasım 2007
Mesajlar
10.379
Beğeniler
2
Şehir
istanbul / bomonti
Üçgen.kare,dikdörtgen ve dairenin alanını hesaplayan program.Karenin ve dairenin tek alanı yazılacağından textbox2 false görünecektir.Öncelikle combobox'ın name özelliğini "c" yapıyoruz ve programın kodlarını yazmaya başlıyoruz.
Kod:
Dim x As New Control
    Dim d As Double
  
  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        c.Text = "Lütfen seçiniz..."
        c.Items.Add("Kare")
        c.Items.Add("Dikdörtgen")
        c.Items.Add("Üçgen")
        c.Items.Add("Daire")
    End Sub
  
Private Function hesapla(ByVal t1 As Double, ByVal t2 As Double) As Double
        If c.SelectedItem = "Kare" Then
            d = t1 * t1
        End If
        If c.SelectedItem = "Üçgen" Then
            d = (t1 * t2) / 2
        End If
        If c.SelectedItem = "Daire" Then
            d = 3.14 * t1 * t1
        End If
        If c.SelectedItem = "Dikdörtgen" Then
            d = t1 * t2
        End If
        Return d
    End Function
    
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label2.Text = hesapla(Val(TextBox1.Text), Val(TextBox2.Text))
    End Sub
  
Private Sub c_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles c.SelectedIndexChanged
        If c.SelectedItem = "Üçgen" Then
            TextBox2.Enabled = True
        End If
        If c.SelectedItem = "Kare" Then
            TextBox2.Enabled = False
        End If
        If c.SelectedItem = "Dikdörtgen" Then
            TextBox2.Enabled = True
        End If
        If c.SelectedItem = "Daire" Then
            TextBox2.Enabled = False
        End If
    End Sub
    Private Sub temizle()
        For Each x In Controls
            If TypeOf x Is TextBox Then
                x.Text = ""
            End If
        Next x
    End Sub
  
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        temizle()
    End Sub
    
Private Sub CIKIS()
        Me.Close()
    End Sub
    
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        CIKIS()
    End Sub
 
Yukarı Alt