Solved

printing a variant in VB

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

condition = ReadFile(PipeHandle, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, 0&)
0
Comment
Question by:oshra
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

691 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