# Visual Basic > Visual Basic 6 and Earlier >  [RESOLVED] LARGE_INTEGER pass to a function by reference

## Kunical

Hi,



Is there a way to pass this LARGE_INTEGER (as a whole) to a function by reference and also making the same function accept Long type?




```
CopyBytes Address, Value.LowPart, 4
CopyBytes Address, Value.HighPart, 4
```



```
Function CopyBytes(Destination As Long, Bytes As Long, ByVal Size As Long)
    Call CopyMemoryWrite(ByVal Destination, Bytes , Size)
    Destination = Destination + Size
End Function
```

I can change Bytes As Long to Bytes As LARGE_INTEGER but I will lose the ability to pass Long values.

How can I make CopyBytes accept Long and LARGE_INTEGER as a reference?

ie,


```
CopyBytes Address, Value, 8
```



```
CopyBytes Address, ValueAsLong, 4
```

----------


## georgekar

Use a variant and check type




```
Function CopyBytes(Destination As Long, Bytes)
    if vartype(Bytes)=vblong then

        Call CopyMemoryWrite(ByVal Destination, Bytes , 4)
        Destination = Destination + 4
    else
        Call CopyMemoryWrite(ByVal Destination, Bytes , 8)
        Destination = Destination + 8
    end if
    Destination = Destination + Size
End Function
```

----------


## Arnoutdv

This thread is an interesting read:
https://www.vbforums.com/showthread....rType-Question

----------


## wqweto

> How can I make CopyBytes accept Long and LARGE_INTEGER as a reference?


You can refactor CopyBytes to use pointers like this



```
Function CopyBytes(Destination As Long, ByVal BytesPtr As Long, ByVal Size As Long)
    Call CopyMemoryWrite(ByVal Destination, ByVal BytesPtr, Size)
    Destination = Destination + Size
End Function
```

. . . and change callsites to use VarPtr like this



```
CopyBytes Address, VarPtr(Value), 8
```



```
CopyBytes Address, VarPtr(ValueAsLong), 4
```

The idea is that using pointers allows you to pass VarPtr to any data-type incl. UDTs.

cheers,
</wqw>

----------


## Kunical

Issue resolved. Thanks to you all for your suggestions!

----------

