Bạn có thể viết 1 hàm số như sau:
 
Private Function tachheso(hamso As String, bac As Integer)
Dim j, i, m As Integer
Dim a(0 To 100)
Dim b(0 To 100)
hamso = Trim(hamso)
' Tim he so bac 0
For j = Len(hamso) To 1 Step -1
      If Mid(hamso, j, 1) = " " Then
         a(0) = Right(hamso, Len(hamso) - j)
               For m = 1 To Len(a(0))
                    If Mid(a(0), m, 1) = "x" Then
                      a(0) = 0
                     Exit For
                    End If
               Next
          Exit For
       End If
Next
' Tim cac he so bac 1,2,3,4,...
For j = 1 To Len(hamso) Step 1
      If Mid(hamso, j, 1) = "x" Then
         If Mid(hamso, j + 1, 1) = " " Or Mid(hamso, j + 1, 1) = "" Then
            i = 1
          Else: i = Mid(hamso, j + 1, 1)
       End If
          For m = j To 1 Step -1
                  If Mid(hamso, m, 1) = " " Then
                     a(i) = Trim(Mid(hamso, m, j - m))
                     Exit For
                  End If
            Next
      End If
Next
tachheso = a(bac)
End Function