# Visual Basic > Games and Graphics Programming > Game Demos >  [Vb.Net] Rock-Paper-Scissors

## dday9

This is just the source code.

Notes:
This is for a console application, it's pretty easy to convert to a windows form application though.

Source:

vb.net Code:
Option Strict On
Option Explicit On
Module Module1
    'New random object
    Private r As New Random
     Sub Main()
        'Loop indefinitely
        Do While True = True
             'Get the user input
            Dim user_input As String = String.Empty
             'Loop until the user input isn't empty
            Do While user_input = String.Empty
                Console.WriteLine("Please type in: Rock, Paper, or Scissors")
                 Dim input As String = Console.ReadLine
                If input.ToLowerInvariant = "rock" OrElse input.ToLowerInvariant = "paper" OrElse input.ToLowerInvariant = "scissors" Then
                    user_input = input
                End If
            Loop
             'Get the computer's input from the AI function
            Dim comp_input As String = AI()
             'Write out...
            'You picked: <rock/paper/scissors>
            'The computer picked: <rock/paper/scissors>
            Console.Write(String.Format("You picked: {0}{1}The computer picked: {2}{1}", user_input, Environment.NewLine, comp_input))
            
            'Now type if it's a win, lose, or draw
            If user_input = comp_input Then
                Console.WriteLine("It's a draw.")
            ElseIf user_input = "rock" AndAlso comp_input = "paper" OrElse _
                user_input = "paper" AndAlso comp_input = "scissors" OrElse _
                user_input = "scissors" AndAlso comp_input = "rock" Then
                Console.WriteLine("You lost...")
            ElseIf user_input = "rock" AndAlso comp_input = "scissors" OrElse _
                user_input = "paper" AndAlso comp_input = "rock" OrElse _
                user_input = "scissors" AndAlso comp_input = "paper" Then
                Console.WriteLine("You won!")
            End If
             Console.WriteLine()
        Loop
    End Sub
     Private Function AI() As String
        'Get a random number from 0 - 2
        'Return rock, paper, or scissors based on that random number
        Select Case r.Next(0, 3)
            Case 0
                Return "rock"
            Case 1
                Return "paper"
            Case 2
                Return "scissors"
            Case Else
                Return "error"
        End Select
    End Function
 End Module

----------

