Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You may have an overflow due the maximum integer size; the currency type actually does very well for large numbers (but beware of any regional issues). See edits below for Int64 discussion.</p> <p>According to MSDN documentation on <a href="http://msdn.microsoft.com/en-us/library/6cd3f6w1.aspx" rel="noreferrer">IsNumeric</a>:</p> <ul> <li><p>IsNumeric returns True if the data type of Expression is Boolean, Byte, Decimal, Double, Integer, Long, SByte, Short, Single, UInteger, ULong, or UShort, or an Object that contains one of those numeric types. It also returns True if Expression is a Char or String that can be successfully converted to a number. </p></li> <li><p>IsNumeric returns False if Expression is of data type Date or of data type Object and it does not contain a numeric type. IsNumeric returns False if Expression is a Char or String that cannot be converted to a number.</p></li> </ul> <p>Since you are getting a Type Mismatch, perhaps a Double is interfering with the conversion. The IsNumeric does not guarantee it is an Integer, just that it matches one of the numeric possibilities. If the number is a double, perhaps regional settings (comma versus period and so on) are causing the exception.</p> <p>You might try converting it to a double and then to an integer.</p> <pre><code>' Using a couple of steps Dim iValue As Integer Dim dValue As Double dValue = CDbl(SourceValue) iValue = CInt(iValue) ' Or in one step (might make debugging harder) iValue = CInt(CDbl(SourceValue)) </code></pre> <p>EDIT: After your clarification, it appears you are getting an overflow conversion. First try using a Long and CLng() instead of CInt(). There is still a chance the entry is Int64 though, which is more difficult using VB6.</p> <p>I have used the following code for the LARGE_INTEGER and Integer8 types (both Int64), but it may not work for your situation:</p> <pre><code>testValue = CCur((inputValue.HighPart * 2 ^ 32) + _ inputValue.LowPart) / CCur(-864000000000) </code></pre> <p>This example was from an <a href="http://support.microsoft.com/kb/323750" rel="noreferrer">LDAP password expiration example</a>, but like I said it may or may not work in your scenario. If you don't have the LARGE_INTEGER type, it looks like:</p> <pre><code>Private Type LARGE_INTEGER LowPart As Long HighPart As Long End Type </code></pre> <p>Search for LARGE_INTEGER and VB6 for more information.</p> <p>EDIT: For debugging, it may be useful to temporarily avoid error handling and then turn it back on after passing the troubling lines:</p> <pre><code>If IsNumeric(strMaxAlternatives) And strMaxAlternatives &lt;&gt; "" Then On Error Resume Next iGlobalMaxAlternatives = CInt(strMaxAlternatives) If Err.Number &lt;&gt; 0 Then Debug.Print "Conversion Error: " &amp; strMaxAlternatives &amp; _ " - " &amp; Err.Description EndIf On Error Goto YourPreviousErrorHandler End If </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload