[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 196
  • Last Modified:

printing a variant in VB

How can i print the lpBuffer:

condition = ReadFile(PipeHandle, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, 0&)
0
oshra
Asked:
oshra
  • 4
  • 4
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
Hope your code writes like this:
nNumberOfBytesToRead = 100  'Example
lpBuffer = Space ( nNumberOfBytesToRead )
condition = ReadFile (...)
DEBUG.PRINT left(lpBuffer,lpNumberOfBytesRead)
0
 
oshraAuthor Commented:
That My code:
The application fail in ReadFile function.

lpBuffer = Space(nNumberOfBytesToRead)
     While condition = 0
        condition = ReadFile(PipeHandle, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, 0&) 'lpOverlapped)
        If condition Then
            MsgBox Left(lpBuffer, lpNumberOfBytesRead)
        End If
     Wend

The ReadFile function defined that way:
Public Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal lpOverlapped As Long) As Long
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
What/Where is your problem?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
oshraAuthor Commented:
When i add the lines u segest The application start fail in ReadFile function.
before that she pass that but i could not see what in the lpBuffer.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
Transform your declaration as follows:
Public Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long,  lpBuffer As String, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal lpOverlapped As Long) As Long
0
 
oshraAuthor Commented:
i did it but now:
if i declere lpBuffer As Variant
i get Compile Error: Type Mismatch.
if i declere lpBuffer As String
the application fail in run time.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
UUPS (sorry)
Public Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long,  BYVAL lpBuffer As String, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal lpOverlapped As Long) As Long

0
 
ivysoftCommented:
i agree with angelIII
BYVAL lpBuffer As String
should work

Brij
0
 
oshraAuthor Commented:
It Works!!
Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now