I’m sorry i messed up the name of this post, the Mid function has nothing to do with this.
Private Sub SeparateandReverseCardNumber(ByVal FullCardNumber As Integer) 'This procedure separates CardNumber into an array, Reverses the array and 'stores the check digit. For counter = 1 To Len(CStr(FullCardNumber - 1)) SeparatedCardNumbers(counter) = Mid(FullCardNumber, counter, 1) Next Array.Reverse(SeparatedCardNumbers) CheckDigit = Mid(CInt(FullCardNumber), 8, 1) End Sub
The problem lies in this procedure. If FullCardNumber starts with a 0, the for loop inside the procedure treats it as “” and my program fails due to a run time error
An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll Additional information: Conversion from string "" to type 'Integer' is not valid.
I am sorry if this is confusing because i cannot explain the situation correctly. Please ask me for any more info that is required.