G
Guest
I have a module that was created for me. I have used it with no problem
until now. The whole thing looks like this:
Function GetQty(PackagingString As String) As Long
Dim lngOut As Long
lngOut = 1
Dim intLen As Integer
Dim intChar As Integer 'which character to examine
Dim intNum As Integer 'found number in string
intLen = Len(PackagingString)
For intChar = 1 To intLen
If IsNumeric(Mid(PackagingString, intChar, 1)) Then
'get the value of the found number
intNum = Val(Mid(PackagingString, intChar))
'multiply the values
lngOut = lngOut * intNum
'skip characters to a non-numeric
intChar = intChar + Len(Trim(Str(intNum)))
End If
Next
GetQty = lngOut
End Function
Now I am getting a Debug on this:
intNum = Val(Mid(PackagingString, intChar))
Some of the packaging strings have descriptions in them like this:
CS/25CT/20EA SINGLE SWABSTICK
Most of them look like this:
BX/12EA
CS/2BX/24PK/8EA
CS/30BG/5EA
If I hit cancel on the Debug then I get:
Run-time error '6'
Overflow
Any help would be appreciated. Also, if you could explain why this is
happening that would be great as well.
Thomas
until now. The whole thing looks like this:
Function GetQty(PackagingString As String) As Long
Dim lngOut As Long
lngOut = 1
Dim intLen As Integer
Dim intChar As Integer 'which character to examine
Dim intNum As Integer 'found number in string
intLen = Len(PackagingString)
For intChar = 1 To intLen
If IsNumeric(Mid(PackagingString, intChar, 1)) Then
'get the value of the found number
intNum = Val(Mid(PackagingString, intChar))
'multiply the values
lngOut = lngOut * intNum
'skip characters to a non-numeric
intChar = intChar + Len(Trim(Str(intNum)))
End If
Next
GetQty = lngOut
End Function
Now I am getting a Debug on this:
intNum = Val(Mid(PackagingString, intChar))
Some of the packaging strings have descriptions in them like this:
CS/25CT/20EA SINGLE SWABSTICK
Most of them look like this:
BX/12EA
CS/2BX/24PK/8EA
CS/30BG/5EA
If I hit cancel on the Debug then I get:
Run-time error '6'
Overflow
Any help would be appreciated. Also, if you could explain why this is
happening that would be great as well.
Thomas