I have a text box which holds four digits. I want to total those digits and get the last number.
Ok I know I could do it as below
Dim num1 As Integer
Dim num2 As Integer
Dim num3 As Integer
Dim num4 As Integer
Dim num5 As Integer
Dim num6 As Integer
num1 = 1234
num2 = Mid(num1, 1, 1)
num3 = Mid(num1, 2, 1)
num4 = Mid(num1, 3, 1)
num5 = Mid(num1, 4, 1)
num6 = num2 + num3 + num4 + num5
If Len(Num6) = 2
NumRequired = Mid(Num6,2,1)
Else
NumRequired = Num6
End If
I was wondering if there was an easier and quicker way of doing it?
Ok I know I could do it as below
Dim num1 As Integer
Dim num2 As Integer
Dim num3 As Integer
Dim num4 As Integer
Dim num5 As Integer
Dim num6 As Integer
num1 = 1234
num2 = Mid(num1, 1, 1)
num3 = Mid(num1, 2, 1)
num4 = Mid(num1, 3, 1)
num5 = Mid(num1, 4, 1)
num6 = num2 + num3 + num4 + num5
If Len(Num6) = 2
NumRequired = Mid(Num6,2,1)
Else
NumRequired = Num6
End If
I was wondering if there was an easier and quicker way of doing it?