Solved

printing a variant in VB

Posted on 2000-03-23
9
175 Views
Last Modified: 2006-11-17
How can i print the lpBuffer:

condition = ReadFile(PipeHandle, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, 0&)
0
Comment
Question by:oshra
  • 4
  • 4
9 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 2648687
Hope your code writes like this:
nNumberOfBytesToRead = 100  'Example
lpBuffer = Space ( nNumberOfBytesToRead )
condition = ReadFile (...)
DEBUG.PRINT left(lpBuffer,lpNumberOfBytesRead)
0
 

Author Comment

by:oshra
ID: 2648745
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
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 2648759
What/Where is your problem?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:oshra
ID: 2648775
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
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 2648799
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
 

Author Comment

by:oshra
ID: 2648841
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
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 20 total points
ID: 2648882
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
 

Expert Comment

by:ivysoft
ID: 2649928
i agree with angelIII
BYVAL lpBuffer As String
should work

Brij
0
 

Author Comment

by:oshra
ID: 2652170
It Works!!
Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question