Option Explicit On

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim s1 As String, s2 As String, v1 As Object
        Dim i As Integer, j As Integer, k As Integer, n As Integer, length As Integer
        Dim a As Integer, b As Integer
        Dim x As Integer, y As Integer

        s1 = TextBox1.Text
        s1 = Trim(s1)
        length = Len(s1)

        n = 0
        a = 0
        b = 0

        i = 1
        For k = i To length
            v1 = Mid(s1, k, 1)
            If (v1 >= "0" And v1 <= "9") Then
                n = n * 10 + v1
            Else
                GoTo Next_step1
            End If
        Next k

Next_step1:
        i = k
        s2 = Trim(Mid(s1, i + 1, length - i))
        For k = 1 To length - i
            v1 = Mid(s2, k, 1)
            If (v1 >= "0" And v1 <= "9") Then
                a = a * 10 + v1
            Else
                GoTo Next_step2
            End If
        Next k

Next_step2:
        i = i + k
        s2 = Trim(Mid(s1, i + 1, length - i))
        For k = 1 To length - i
            v1 = Mid(s2, k, 1)
            If (v1 >= "0" And v1 <= "9") Then
                b = b * 10 + v1
            Else
                GoTo Next_step3
            End If
        Next k

Next_step3:
        If (a < b) Then
            x = a
        Else
            x = b
        End If

        If (a + b - n > 0) Then
            y = a + b - n
        Else
            y = 0
        End If

        TextBox3.Text = x & " " & y
    End Sub

End Class
