Thursday, February 16, 2012


Option Explicit

Sub PracticeInIfs1()
    Number = InputBox("Please guess a number")
    If Number = "7" Then
        Debug.Print "You got it!!"
    ElseIf Number = 6 Then
        Debug.Print "Close! Try guessing a little higher."
    Else
        Debug.Print "You were way off! Sorry..."
    End If
End Sub

Sub PracticeInIfs2()
    Name = InputBox("Please enter your name")
    If Name = "Sam" Then
        Debug.Print "you are Sam!"
    Else
        Debug.Print "you are not Sam!"
    End If
End Sub

Sub PracticeInIfs3()
    Dim Number As Integer
    Number = InputBox("Please guess a number")
    If Number = "5" Then
        Debug.Print "equals"
    ElseIf Number > 5 Then
        Debug.Print "greater"
    ElseIf Number < 5 Then
        Debug.Print "less than"
    End If
End Sub

No comments:

Post a Comment