|
-
May 10th, 2007, 08:28 AM
#1
Thread Starter
Addicted Member
[2005]Expected Expression on ByVal 0&
I'm converting some code from VB6 to .NET (2005) but it didn't manage to handle everything in the autoconvert. Now I have a few errors left in this code:
Code:
Private Declare Function ReadFile _
Lib "kernel32" ( _
ByVal hFile As Long, _
ByVal lpBuffer As Object, _
ByVal nNumberOfBytesToRead As Long, _
ByVal lpNumberOfBytesRead As Long, _
ByVal lpOverlapped As Object) As Long
Do
' Add a DoEvents to allow more data to be written to the buffer for each call.
' This results in fewer, larger chunks to be read.
'DoEvents
If ReadFile(hPipeRead, baOutput(0), BUFSIZE, lBytesRead, ByVal 0&) = 0 Then
Exit Do
End If
If blnOEMConvert Then
' convert from "DOS" to "Windows" characters
sNewOutput = CChar(CChar(CStr(lBytesRead)))
Call OemToCharBuff(baOutput(0), sNewOutput, lBytesRead)
Else
' perform no conversion (except to Unicode)
sNewOutput = Left$(StrConv(baOutput(0), 64), lBytesRead)
End If
GetCommandOutput = GetCommandOutput & sNewOutput
' If you are executing an application that outputs data during a long time,
' and don't want to lock up your application, it might be a better idea to
' wrap this code in a class module in an ActiveX EXE and execute it asynchronously.
' Then you can raise an event here each time more data is available.
'RaiseEvent OutputAvailabele(sNewOutput)
Loop
The stuff in magenta is giving errors. I am not sure what to do about the ByVal 0& stuff.
-
May 10th, 2007, 08:32 AM
#2
Re: [2005]Expected Expression on ByVal 0&
API functions in .NET need to be changed a bit from VB6.
try using this as your API dec
Code:
<DllImport("kernel32.dll")> Friend Shared Function ReadFile( _
ByVal File As SafeFileHandle, _
ByVal Buffer As System.Text.StringBuilder, _
ByVal NumberOfBytesToRead As Integer, _
ByRef NumberOfBytesRead As Integer, _
ByRef Overlapped As System.Threading.NativeOverlapped) As SafeFileHandle
End Function
and then changing where you call it to match these new params.
Also I am not sure what your code does, but the .NET framework has LOADS of file IO functions built right in that were pretty much non existant in VB6.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|