textbox’lara girilen yazılı notlarının ortalamasını hesaplama Vb.Net

textbox’lara girilen yazılı notlarının ortalamasını hesaplama Vb.Net 

 

 

[code lang=”vbnet”] 

Public Class Form1 

Dim sinav1, sinav2, ort As Integer 

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged 

If TextBox2.Text <> "" And IsNumeric(TextBox2.Text) Then 

If TextBox2.Text > 100 Then 

MessageBox.Show("Hatalı Giriş") 

TextBox2.Clear() 

TextBox3.Clear() 

TextBox4.Clear() 

TextBox5.Clear() 

TextBox4.BackColor = Color.White 

ElseIf TextBox1.Text <> "" And IsNumeric(TextBox1.Text) Then 

sinav1 = TextBox1.Text 

sinav2 = TextBox2.Text 

ort = (sinav1 + sinav2) / 2 

TextBox3.Text = ort 

If ort >= 45 Then 

TextBox3.BackColor = Color.GreenYellow 

Else 

TextBox3.BackColor = Color.Red 

End If 

End If 

Else 

TextBox3.Clear() 

TextBox4.Clear() 

TextBox3.BackColor = Color.White 

End If 

End Sub 

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged 

If TextBox1.Text <> "" And IsNumeric(TextBox1.Text) Then 

If TextBox1.Text > 100 Then 

MessageBox.Show("Hatalı Giriş") 

TextBox3.Clear() 

TextBox4.Clear() 

TextBox5.Clear() 

TextBox4.BackColor = Color.White 

ElseIf TextBox2.Text <> "" And IsNumeric(TextBox2.Text) Then 

sinav1 = TextBox1.Text 

sinav2 = TextBox2.Text 

ort = (sinav1 + sinav2) / 2 

TextBox3.Text = ort 

If ort > 44 Then 

TextBox4.BackColor = Color.GreenYellow 

Else 

TextBox4.BackColor = Color.Red 

End If 

Else 

TextBox4.Clear() 

TextBox5.Clear() 

TextBox4.BackColor = Color.White 

End If 

End If 

End Sub 

Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged 

If TextBox3.Text <> "" Then 

If TextBox3.Text >= 85 Then 

TextBox4.Text = 5 

TextBox5.Text = "Geçti" 

ElseIf TextBox3.Text >= 70 Then 

TextBox4.Text = 4 

TextBox5.Text = "Geçti" 

ElseIf TextBox3.Text >= 55 Then 

TextBox5.Text = "Geçti" 

TextBox4.Text = 3 

ElseIf TextBox3.Text >= 45 Then 

TextBox4.Text = 2 

TextBox5.Text = "Geçti" 

ElseIf TextBox3.Text >= 24 Then 

TextBox4.Text = 1 

TextBox5.Text = "Kaldı" 

Else 

TextBox4.Text = 0 

TextBox5.Text = "Kaldı" 

End If 

End If 

End Sub 

End Class 

[/code]

 

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir