PDA

ดูเวอร์ชั่นเต็ม : ขอความช่วยเหลือด้าด ภาษา vb ด่วน



residentevil190
8th July 2012, 15:21
Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Point As Integer = CInt(TextBox1.Text)
Dim Grade As String = CInt(TextBox2.Text)


If Point <= 80 Then
Grade("a")
End If

If Point <= 75 Then
Grade("b+")
End If

If Point <= 70 Then
Grade("b")
End If

If Point <= 65 Then
Grade("c+")
End If

If Point <= 60 Then
Grade("c")
End If

If Point <= 55 Then
Grade("d+")
End If

If Point <= 50 Then
Grade("d")
End If

If Point >= 49 Then
Grade("e")
End If


Else

End Sub
End Class


อยากทราบมันผิดต่อไหนรันไม่ผ่านสักที (ส่วนที่ขีดเส้นใต้มันมีตรงนั้นซึ่งไม่เข้าใจเลย) ผมอาจมองข้ามไปส่วนหนึ่งซึ่งยังไม่เห็นสักที
ขอบคุณครับที่ให้ความช่วยเหลือ

arada_vivi
8th July 2012, 15:27
ลองแก้เป็น




If ... Then
....
elseif .... Then

end if

ดูครับ

AkiyamaREN
8th July 2012, 15:37
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim score As Integer = CInt(TextBox1.Text)
Dim grade As String

If score >= 80 Then
grade = "a"

ElseIf score >= 75 Then
grade = "b+"

ElseIf score >= 70 Then
grade = "b"

ElseIf score >= 65 Then
grade = "c+"

ElseIf score >= 60 Then
grade = "c"

ElseIf score >= 55 Then
grade = "d+"

ElseIf score >= 50 Then
grade = "d"

Else
grade = "e"

End If

TextBox2.Text = grade.ToString()

End Sub

residentevil190
8th July 2012, 15:39
ขอบคุณครับ

residentevil190
8th July 2012, 16:26
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim point As Integer = CInt(TextBox1.Text)
Dim grade As String

If point >= 80 Then
grade = "a"

ElseIf point >= 75 Then
grade = "b+"

ElseIf point >= 70 Then
grade = "b"

ElseIf point >= 65 Then
grade = "c+"

ElseIf point >= 60 Then
grade = "c"

ElseIf point >= 55 Then
grade = "d+"

ElseIf point >= 50 Then
grade = "d"

Else
grade = "e"

End If

TextBox2.Text = grade

End Sub
End Class