?
Solved

printing a variant in VB

Posted on 2000-03-23
9
Medium Priority
?
191 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 80 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 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…
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…
Suggested Courses

649 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