Hi, I'm trying to write sub procedure to check the winner for Rock, Paper, Sissors game. The below code runs fine but it's not showing the winner on the result label any help would be greatly appreciated.

Imports System.Random
Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    End Sub
    Private Sub getChoices(sender As Object, e As EventArgs) Handles BtnChoice.Click
        Dim r As Random = New Random
        Dim rr As Integer = r.Next(0, 3)
        Dim cChoice As Char = CChar(CStr(rr))
        Dim strChoice As String
        Dim Msg = "Illegal entry, pick again"

        strChoice = InputBox("Pick (P)aper, (R)ock or (S)cissor", "TestProgram")
        strChoice.ToUpper()
        If (strChoice <> "R" And strChoice <> "r") And (strChoice <> "P" And strChoice <> "p") And (strChoice <> "S" And strChoice <> "s") Then
            MessageBox.Show(Msg)
        End If
        If strChoice = vbNullString Then
            Return

        Else
            Select Case strChoice

                Case "r"
                    strChoice = "Rock"
                    lblUserChoice.Text = strChoice
                Case "p"
                    strChoice = "Paper"
                    lblUserChoice.Text = strChoice
                Case "s"
                    strChoice = "Scissor"
                    lblUserChoice.Text = strChoice
            End Select
            Select Case r.Next(0, 3)
                Case 0
                    cChoice = "Rock"
                    lblCompChoice.Text = "Rock"
                Case 1
                    cChoice = "Paper"
                    lblCompChoice.Text = "Paper"
                Case 2
                    cChoice = "Scssor"
                    lblCompChoice.Text = "Scissor"
            End Select
        End If
    End Sub
    Sub whoWins(strChoice, cChoice)
        If (strChoice = cChoice) Then
            lblResult.Text = "Draw"

            If (cChoice = "Rock") Then
                If (strChoice = "p") Then
                    lblResult.Text = "You Win!"
                Else
                    lblResult.Text = "You Lose!"
                End If
            ElseIf (cChoice = "Paper") Then
                If (strChoice = "r") Then
                    lblResult.Text = "You Lose!"
                Else
                    lblResult.Text = "You Win!"
                End If
            Else
                If (strChoice = "r") Then
                    lblResult.Text = "You Win!"
                Else
                    lblResult.Text = "You Lose!"
                End If
            End If
        End If

    End Sub
    Private Sub lblResult_Click(sender As Object, e As EventArgs) Handles lblResult.Click

    End Sub
End Class

In the code you've posted the sub method whoWins never gets called. Call that method after both hands have picked and it should work

Hi,
Where should I call it and how should I call it can you please explain? Thank you so much

I added below code within the sub getChoices method but it still isn't showing up the results within the result label. Would appreciate if anyone could please help.

Call whoWins(cChoice, strChoice)            
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.