My guess would be that defining your CreateFile function signature with 
lpSecurityAttributes defaulting to ByRef is the problem.

When you call it you are passing a literal 0 value, and the logic invoked to 
make the actual call behind the scenes sees that this cannot be a ByRef because 
the Variant value's VarType doesn't have the VT_BYREF flag set.

Try changing the function signature to call lpSecurityAttributes ByVal instead. 
 This may let you pass the expression/literal 0 to signify a null pointer value.

I could be way off, but it is quick and easy to try.

--- In [email protected], "jose" <jose_gregori...@...> wrote:
>
> i have it program and say error in linea 1 char 4 error type mistmach , i not 
> understaing, please i need help urgent
> 
> form1
> 
> Sub CommandButton1_Click
> 
> Dim lHandle
> Dim lpErrors
> Dim lSuccess
> Dim lBytesWritten
> Dim lBytesToWrite
> Dim TheData
> Dim N
> 
> 
> 
> lHandle = CreateFile("\xx.txt", GENERIC_WRITE or  GENERIC_READ, 0, 0, 
> OPEN_ALWAYS, 0, 0)
> 
> TheData="hola  hola"
> 
> lBytesToWrite = Len(TheData)
> lBytesWritten=0
>  lSuccess =0
>  
> 
> 
> N=0
> 
> 'hear error
>  WriteFile lHandle, TheData, lBytesToWrite, lBytesWritten, N
> 
>  
>    MsgBox "Fino"
>   
> 
> lSuccess = CloseHandle(lHandle)
> 
> End Sub
> 
> module 1
> 
> 
> Public Const GENERIC_WRITE = &H40000000
> Public Const GENERIC_READ = &H80000000
> Public Const FILE_ATTRIBUTE_NORMAL = &H80
> Public Const CREATE_ALWAYS = 2
> Public Const OPEN_ALWAYS = 4
> Public Const INVALID_HANDLE_VALUE = -1
> 
> 
> Declare "Function CreateFile Lib ""Coredll"" Alias ""CreateFileW"" (ByVal 
> lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As 
> Long, lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, 
> ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long"
> 
> Declare "Function WriteFile Lib ""Coredll""  (ByVal hFile As Long, lpBuffer 
> As String, ByVal nNumberOfBytesToWrite As Long, lpNumberOfBytesWritten As 
> Long, lpOverlapped As Long) As Long"
> 
> Declare "Function CloseHandle Lib ""Coredll""  (ByVal hObject As Long) As 
> Long"
> 
> 
> 
> Public Const CE_BREAK = &H10 ' break condition
> Public Const CE_PTO = &H200 ' printer timeout
> Public Const CE_IOE = &H400 ' printer I/O error
> Public Const CE_DNS = &H800 ' device not selected
> Public Const CE_OOP = &H1000 ' out of paper
>


-- 
You received this message because you are subscribed to the Google Groups 
"nsb-ce" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nsb-ce?hl=en.

Reply via email to