Results 1 to 3 of 3

Thread: Type Mismatch

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    116

    Type Mismatch

    I've used this same code multiple times but now it is giving me a type mismatch error. I marked the line that is highlighted when i debug it. Thanks for any help

    VB Code:
    1. Private Function Hex2Dec(ByVal lnHexValue) As Currency
    2.     Dim intLow(1) As Integer, lnHigh(1) As Long, tmpVar
    3.     If UCase$(Left$(lnHexValue, 2)) = "&H" Then tmpVar = Mid$(lnHexValue, 3)
    4.     lnHexValue = Right$("0000000" & lnHexValue, 8)
    5.     If IsNumeric("&H" & lnHexValue) Then
    6.         intLow(0) = CInt("&H" & Right$(lnHexValue, 2)) 'type mismatch
    7.         lnHigh(0) = CLng("&H" & Mid$(lnHexValue, 5, 2))
    8.         intLow(1) = CInt("&H" & Mid$(lnHexValue, 3, 2))
    9.         lnHigh(1) = CLng("&H" & Left$(lnHexValue, 2))
    10.         Hex2Dec = CCur(lnHigh(1) * 256 + intLow(1)) * 65536 + (lnHigh(0) * 256) + intLow(0)
    11.     End If
    12.  
    13. End Function

  2. #2
    Addicted Member
    Join Date
    Apr 2006
    Location
    USA
    Posts
    207

    Re: Type Mismatch

    I tried your function and it seemd to work. Maybe it's the data that's being sent to it.
    Keith_VB6

    If you have any further questions, just ask.
    If this solves things, then please mark the thread resolved.
    [Thread Tools] --> [Mark Thread Resolved]

  3. #3
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Type Mismatch

    Do you realize you are asking for a variant? My guess is that it would work better if you fully qualified your routine a a string.
    VB Code:
    1. Private Function Hex2Dec(ByVal lnHexValue as String) As Currency
    And what does your data look like?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width