# Visual Basic > Office Development >  Code error help

## Rodmac

Can someone tell me tell how to solve the error given by the code bellow?


it gives me a error on the line: HitTest x, y, tHT    the error displayed is " Byref argument type mismatch"



```
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
        (ByVal hwnd As Long, ByVal lMsg As Long, ByVal wParam As Long, _
        lParam As Any) As Long
        
Private Const LVM_FIRST = &H1000&
Private Const LVM_SUBITEMHITTEST = (LVM_FIRST + 57)

Private Type POINTAPI
    x As Long
    y As Long
End Type

Private Type LVHITTESTINFO
    pt As POINTAPI
    lFlags As Long
    lItem As Long
    lSubItem As Long
End Type


'---------------------------------------------------------------

Private Sub HitTest(x As Single, y As Single, tHitTest As LVHITTESTINFO)

    Dim lRet As Long
    Dim lX As Long
    Dim lY As Long

    lX = x / Screen.TwipsPerPixelX
    lY = y / Screen.TwipsPerPixelY

    With tHitTest
        .lFlags = 0
        .lItem = 0
        .lSubItem = 0
        .pt.x = lX
        .pt.y = lY
    End With
    
lRet = SendMessage(ListView1.hwnd, LVM_SUBITEMHITTEST, 0, tHitTest)
   
End Sub

Private Sub ListView1_BeforeLabelEdit(Cancel As Integer)

End Sub

Private Sub ListView1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As stdole.OLE_XPOS_PIXELS, ByVal y As stdole.OLE_YPOS_PIXELS)

Dim tHT As LVHITTESTINFO
HitTest x, y, tHT

 If tHT.lItem + 1 > 0 Then
   If tHT.lSubItem = 1 Then
     ListView1.TooltipText = ListView1.ListItems(tHT.lItem + 1).SubItems(tHT.lSubItem)
   Else
     ListView1.TooltipText = ""
   End If
 End If


End Sub

'------------------------------------------------------------------


Private Sub UserForm_Initialize()



With ListView1
    .ColumnHeaders.Clear
    .View = lvwReport
    '.SmallIcons = ImageList1
    .FullRowSelect = True
    .Gridlines = True
    .ColumnHeaders.Add , , "Id", 20                         '0
    .ColumnHeaders.Add , , "C.Barras", 20, 2               '1
    .ColumnHeaders.Add , , "Descrição do Produto", 280      '2
    .ColumnHeaders.Add , , "Grupo", 70, 2                  '3
    .ColumnHeaders.Add , , "Marca", 70, 2                  '4
    .ColumnHeaders.Add , , "Linha", 70, 2                  '5
    .ColumnHeaders.Add , , "Categoria", 70, 2              '6
    .ListItems.Add , , "dfdf"
    .ListItems(1).ListSubItems.Add , , "frerr"
       .ListItems(1).ListSubItems.Add , , "xxxx"
    
End With

End Sub
```

----------


## OptionBase1

In the code where you are calling:



```
HitTest x, y, tHT
```

x and y have a type of *stdole.OLE_XPOS_PIXELS* (possibly a Long under the hood?), but HitTest is expecting types of *Single* for those parameters.

----------


## Rodmac

> In the code where you are calling:
> 
> 
> 
> ```
> HitTest x, y, tHT
> ```
> 
> x and y have a type of *stdole.OLE_XPOS_PIXELS* (possibly a Long under the hood?), but HitTest is expecting types of *Single* for those parameters.



I'Ve changed x and y to long and it seems that it solved the problem, but it gives another errorsaying screen its a variable not defined in the line  lX = x / Screen.TwipsPerPixelX, so how will i declare this variable?

----------

