Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.CenterToScreen()
GroupBox1.Text = "ป้อนข้อมูล"
Label1.Text = "รหัสนักศึกษา"
Label2.Text = "คำนำหน้า"
Label3.Text = "ชื่อ- สกุล"
Label4.Text = "สถานะ"
Label5.Text = "คะแนนระหว่างภาค"
Label6.Text = "คะแนนปลายภาค"
Label7.Text = ""
Label8.Text = ""
Label10.Text = ""
Label11.Text = ""
Label12.Text = ""
Label13.Text = ""
Label14.Text = ""
Button1.Text = "คำนวณ"
Dim sex(3) As String
sex(0) = "นาย"
sex(1) = "นางสาว"
sex(2) = "นาง"
Dim i As Integer
For i = 0 To 2
ComboBox1.Items.Add(sex(i))
Next
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
ComboBox1.SelectedIndex = 0
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mid, final, sum As Byte
mid = Val(TextBox3.Text)
final = Val(TextBox4.Text)
sum = mid + final
Dim code As String
code = TextBox1.Text
Label7.Text = code
Dim Name As String
Name = TextBox2.Text
Label8.Text = ComboBox1.Text & " " & Name
Label11.Text = mid
Label12.Text = final
Dim s As String
If RadioButton1.Checked = True Then
s = "โสด"
End If
If RadioButton2.Checked = True Then
s = "สมรส"
End If
If RadioButton3.Checked = True Then
s = "หย่าร้าง"
End If
Label10.Text = s
Label14.Text = calgrade(sum)
Label13.Text = sum
End Sub
Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter
End Sub
End Class
Module Module1
Function calgrade(ByVal t1 As String) As String
Dim sum As String
sum = CInt(t1)
Dim g As String
Dim i As Integer
i = CInt(t1)
If sum <= 49 Then
g = "F"
ElseIf sum <= 59 Then
g = "D"
ElseIf sum <= 69 Then
g = "C"
ElseIf sum <= 79 Then
g = "B"
ElseIf sum <= 100 Then
g = "A"
Else : g = "xxxx"
End If
Return g
End Function
End Module
Top |