This macro contains the functions Split() and IsNumeric(), it's all you need:
Sub test()
Dim A, B As Integer
T = Split("1, 2, X", ",")
If IsNumeric(T(0)) Then A = T(0) Else A = -1
If IsNumeric(T(2)) Then B = T(2) Else B = -1
MsgBox "Result : A=[" & CStr(A) & "], B=[" & CStr(B) & "]"
End Sub