Major Help Needed!

Matthew

New member
Joined
Sep 4, 2011
Messages
2
Programming Experience
Beginner
Hi Everyone,

Im new at VB and im stuck on how to complete this code for an assighment..

If anyone could help it would be great!

Here is the Question:
Help.jpg

So Far i have done this code:



Private Sub PassFailButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PassFailButton.Click




If Score1TextBox.Text = String.Empty Then




StatusBoxLabel.Text &= ControlChars.NewLine &
"Score 1 is Blank."


Else




If Not IsNumeric(Score1TextBox.Text) Then




StatusBoxLabel.Text &= ControlChars.NewLine &
"Score 1 is not Numeric."





Else




"Score 2 is not in the Range: 0-10."

Else

If Score3TextBox.Text = String.Empty Then
StatusBoxLabel.Text &= ControlChars.NewLine &
"Score 3 is Blank."

Else

If Not IsNumeric(Score3TextBox.Text) Then
StatusBoxLabel.Text &= ControlChars.NewLine &
"Score 3 is not Numeric."

Else

If Score3TextBox.Text < 0 Or Score3TextBox.Text > 10 Then
StatusBoxLabel.Text &= ControlChars.NewLine &
"Score 3 is not in the Range: 0-10."

Else

End If

End If

End If

End If

End If

End If

End If

End If

End If
End Sub
 
Please help us to help you. First, please use descriptive titles for your threads. Everyone who posts needs help so saying that you need help is of no use. When we open a forum we see a list of threads. We use the titles to decide which ones are relevant to us. If your title doesn't describe doesn't describe the topic of the thread then one of two things will happen:

1. We will just not bother looking at it, in which case you miss out on potential help.
2. We have to open the thread to determine whether it's relevant. Imagine how much time would be wasted if we had to open every thread like that.

Second, please don't post your code snippets as HTML. It's just too hard to read. Please adjust the editor options so that you can paste plain text and use
 tags to format your code via the vb button provided on the editor tool bar.

Finally, please don;t just post your assignment and code and leave it to us to work out from there.  Explain exactly what you're trying to do, e.g. where in the assignment you're up to, and exactly what issue you're having, e.g. what you're stuck on or where and what error occurs in your code.
 
Hi, Sorry about that.

I will remember to do that in the future posts.

The task i am stuck on is writing the code to create Else if... ect statments. As the above html code shows i can do the error message but i cannot do the code to say if it is a PASS or a FAIL according to the requirements ( in the picture)

Thanks again
 
Try not to nest if else, its makes it very hard to read. Also edit your post to do what jmcilhinney said for other readers.
Here's the fix for your code. it will do what you want but you still have to think to apply it to your project, i'm not doing your schoolwork work for you :D

VB.NET:
     Private Sub doWork()
        Dim category As String
        Dim sum As Integer
        Dim result As String
 
        'example set it to A
        category = "A"
        'example set it to 10
        sum = 10
        'set result to null
        result = "unkown"

        Select Case category
            Case "A"
                If sum < 12 Then result = "Fail"
                If sum >= 12 Then result = "Pass"
            Case "B"
                If sum < 16 Then result = "Fail"
                If sum >= 16 Then result = "Pass"
            Case "C"
                If sum < 20 Then result = "Fail"
                If sum >= 20 Then result = "Pass"
            Case Else
                'test for bugs here
        End Select
         MsgBox("the result for category " & category & " was a " & result)
    End Sub
 
Back
Top