' Mr. Minich
' Period 1
' Ch5Demo1
' 12/7/2000
' Purpose - to illustrate the use of the StrComp function

Option Explicit

Private Sub Form_Load()
    ' sets the appropriate display messages
    
    lblPrompt.Caption = "Enter two strings."
    lblAnswer.Caption = ""
    txtString1.Text = ""
    txtString2.Text = ""
    cmdClick.Caption = "Compare (&sensitive)"
    cmdClick2.Caption = "Compare (&insensitive)"
    cmdClear.Caption = "&Clear"
    cmdExit.Caption = "E&xit"
End Sub

Private Sub cmdClick_Click()
    ' determines the alphabetical order of two strings in a case-sensitive manner
    
    Dim intOrder As Integer     ' stores -1, 0, or 1 based on order of two strings
    
    intOrder = StrComp(txtString1.Text, txtString2.Text)
    
    If (intOrder = -1) Then
        lblAnswer.Caption = txtString1.Text & " is less than " & txtString2.Text
    ElseIf (intOrder = 1) Then
        lblAnswer.Caption = txtString2.Text & " is less than " & txtString1.Text
    ElseIf (intOrder = 0) Then
        lblAnswer.Caption = txtString2.Text & " is the same as " & txtString1.Text
    End If
    
    txtString1.SetFocus
    
End Sub

Private Sub cmdClick2_Click()
    ' determines the alphabetical order of two strings in a case-insensitive manner
    
    Dim intOrder As Integer     ' stores -1, 0, or 1 based on order of two strings
    
    intOrder = StrComp(txtString1.Text, txtString2.Text, 1) ' the 1 parameter makes
                                                            '   the test sensitive
    
    If (intOrder = -1) Then
        lblAnswer.Caption = txtString1.Text & " is less than " & txtString2.Text
    ElseIf (intOrder = 1) Then
        lblAnswer.Caption = txtString2.Text & " is less than " & txtString1.Text
    ElseIf (intOrder = 0) Then
        lblAnswer.Caption = txtString2.Text & " is the same as " & txtString1.Text
    End If
    
    txtString1.SetFocus
    
End Sub

Private Sub cmdClear_Click()
    ' clears text boxes and output label and sets focus appropriately
    
    txtString1.Text = ""
    txtString2.Text = ""
    lblAnswer.Caption = ""
    txtString1.SetFocus
End Sub


Private Sub cmdExit_Click()
    ' unloads the form and ends the program
    
    Unload Me
    End
End Sub