Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

USB function , ByRef argument type mismatch
Dear All,

I meet a problem when I compile my USB code, and I get this error
message

============================
Compile error:
ByRef argument type mismatch
============================

This problem happen at

 ========================================
==========
Function GetNameOf$(DeviceName$, DeviceHandle&, API_ID&)
...
Status& = DeviceIoControl(DeviceHandle&, API_ID&, 0, 0,
NameBuffer.Length, 260, BytesReturned&, 0)

^^^^^^
cursor stops at at "Length"
...
...
 ========================================
==========

It is the problem "ByRef argument type mismatch"

Set ByValue?


Best regards,
Boki.

Report this thread to moderator Post Follow-up to this message
Old Post
boki
09-29-04 08:55 PM


RE: USB function , ByRef argument type mismatch
Without see all of your code it's a crap-shoot for me, but I'd guess that
NameBuffer.Length is a Long (or Integer), and the arg position where you are
using it the function is expecting a string, not a Long (or Int).  Did you
mean to use NameBuffer.Name?  Or just NameBuffer or something like that?

P.S. if you ever get tired of typing all those dollar signs and ampersands
you might want to learn to Dim your variables instead!


"boki" wrote:

> Dear All,
>
>  I meet a problem when I compile my USB code, and I get this error
> message
>
> ============================
> Compile error:
> ByRef argument type mismatch
> ============================
>
> This problem happen at
>
>  ========================================
==========
>   Function GetNameOf$(DeviceName$, DeviceHandle&, API_ID&)
> ....
> Status& = DeviceIoControl(DeviceHandle&, API_ID&, 0, 0,
> NameBuffer.Length, 260, BytesReturned&, 0)
>
> ^^^^^^
>                                   cursor stops at at "Length"
> ....
> ....
>  ========================================
==========
>
> It is the problem "ByRef argument type mismatch"
>
> Set ByValue?
>
>
> Best regards,
> Boki.
>

Report this thread to moderator Post Follow-up to this message
Old Post
Charlie
09-29-04 08:55 PM


Re: USB function , ByRef argument type mismatch
See if the declaration and calling syntax for DeviceIoControl from
http://vbnet.mvps.org/code/disk/deviodriveinfo.htm helps. Without your
declare and exact code, we can't really guess.

--


Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/


"boki" <bokiteam@ms21.hinet.net> wrote in message
news:4c3c095a.0409290840.63691a5a@posting.google.com...
: Dear All,
:
:  I meet a problem when I compile my USB code, and I get this error
: message
:
: ============================
: Compile error:
: ByRef argument type mismatch
: ============================
:
: This problem happen at
:
:  ========================================
==========
:   Function GetNameOf$(DeviceName$, DeviceHandle&, API_ID&)
: ...
: Status& = DeviceIoControl(DeviceHandle&, API_ID&, 0, 0,
: NameBuffer.Length, 260, BytesReturned&, 0)
:
: ^^^^^^
:                                   cursor stops at at "Length"
: ...
: ...
:  ========================================
==========
:
: It is the problem "ByRef argument type mismatch"
:
: Set ByValue?
:
:
: Best regards,
: Boki.


Report this thread to moderator Post Follow-up to this message
Old Post
Randy Birch
09-30-04 02:27 AM


Re: USB function , ByRef argument type mismatch
Dear All,
This is my declaration about CreatFile:

Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _
(ByVal lpFileName$, ByVal dwDesiredAccess&, ByVal dwShareMode&,
lpSecurityAttributes&, _
ByVal dwCreationDisposition&, ByVal dwFlagsAndAttributes&, ByVal
hTemplateFile&) As Long

Thank you very much for your help.

Best regards,
Boki.

"Charlie" <Charlie@discussions.microsoft.com> wrote in message news:<97DA6951-68F7-4AE7-B39
8-86598A62B7BC@microsoft.com>...
> Without see all of your code it's a crap-shoot for me, but I'd guess that
> NameBuffer.Length is a Long (or Integer), and the arg position where you a
re
> using it the function is expecting a string, not a Long (or Int).  Did you
> mean to use NameBuffer.Name?  Or just NameBuffer or something like that?
>
> P.S. if you ever get tired of typing all those dollar signs and ampersands
> you might want to learn to Dim your variables instead!
>
>
> "boki" wrote:
> 

Report this thread to moderator Post Follow-up to this message
Old Post
boki
09-30-04 02:27 AM


Re: USB function , ByRef argument type mismatch
You indicated you had a problem with DeviceIoControl, not CreateFile.  Post
your declare for DeviceIoControl, as well as all the code - including the
Dim's - for the local variables in the routine causing the problem.  Also
provide, from your exact code, precisely what NameBuffer.Length is.

--


Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/


"boki" <bokiteam@ms21.hinet.net> wrote in message
news:4c3c095a.0409291706.5125b04d@posting.google.com...
: Dear All,
:          This is my declaration about CreatFile:
:
: Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _
: (ByVal lpFileName$, ByVal dwDesiredAccess&, ByVal dwShareMode&,
: lpSecurityAttributes&, _
:  ByVal dwCreationDisposition&, ByVal dwFlagsAndAttributes&, ByVal
: hTemplateFile&) As Long
:
: Thank you very much for your help.
:
: Best regards,
: Boki.
:
: "Charlie" <Charlie@discussions.microsoft.com> wrote in message
news:<97DA6951-68F7-4AE7-B398-86598A62B7BC@microsoft.com>...
: > Without see all of your code it's a crap-shoot for me, but I'd guess
that
: > NameBuffer.Length is a Long (or Integer), and the arg position where you
are
: > using it the function is expecting a string, not a Long (or Int).  Did
you
: > mean to use NameBuffer.Name?  Or just NameBuffer or something like that?
: >
: > P.S. if you ever get tired of typing all those dollar signs and
ampersands
: > you might want to learn to Dim your variables instead!
: >
: >
: > "boki" wrote:
: >
: > > Dear All,
: > >
: > >  I meet a problem when I compile my USB code, and I get this error
: > > message
: > >
: > > ============================
: > > Compile error:
: > > ByRef argument type mismatch
: > > ============================
: > >
: > > This problem happen at
: > >
: > >  ========================================
==========
: > >   Function GetNameOf$(DeviceName$, DeviceHandle&, API_ID&)
: > > ....
: > > Status& = DeviceIoControl(DeviceHandle&, API_ID&, 0, 0,
: > > NameBuffer.Length, 260, BytesReturned&, 0)
: > >
: > > ^^^^^^
: > >                                   cursor stops at at "Length"
: > > ....
: > > ....
: > >  ========================================
==========
: > >
: > > It is the problem "ByRef argument type mismatch"
: > >
: > > Set ByValue?
: > >
: > >
: > > Best regards,
: > > Boki.
: > >


Report this thread to moderator Post Follow-up to this message
Old Post
Randy Birch
09-30-04 09:44 AM


Re: USB function , ByRef argument type mismatch
Thanks to all, there are the code:

==A. bas=====================================
========
Declare Function DeviceIoControl Lib "kernel32" _
(ByVal hDevice As Long, ByVal dwIoControlCode As Long, lpInBuffer As Byte,
ByVal nInBufferSize As Long, _
lpOutBuffer As Byte, ByVal nOutBufferSize As Long, lpBytesReturned As Long,
lpOverlapped As Long) As Long
.......
.......
Public Type UNameType: Length As Long: UnicodeName(256) As Byte: End Type

=A. frm=====================================
==============

Dim NameBuffer As UNameType
.......

 ========================================
================


Best regards,
Boki.


"Randy Birch" <rgb_removethis@mvps.org> ???
news:enWGU8ppEHA.3688@TK2MSFTNGP09.phx.gbl ???...
> You indicated you had a problem with DeviceIoControl, not CreateFile.
Post
> your declare for DeviceIoControl, as well as all the code - including the
> Dim's - for the local variables in the routine causing the problem.  Also
> provide, from your exact code, precisely what NameBuffer.Length is.
>
> --
>
>
> Randy Birch
> MS MVP Visual Basic
> http://vbnet.mvps.org/
>
>
> "boki" <bokiteam@ms21.hinet.net> wrote in message
> news:4c3c095a.0409291706.5125b04d@posting.google.com...
> : Dear All,
> :          This is my declaration about CreatFile:
> :
> : Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _
> : (ByVal lpFileName$, ByVal dwDesiredAccess&, ByVal dwShareMode&,
> : lpSecurityAttributes&, _
> :  ByVal dwCreationDisposition&, ByVal dwFlagsAndAttributes&, ByVal
> : hTemplateFile&) As Long
> :
> : Thank you very much for your help.
> :
> : Best regards,
> : Boki.
> :
> : "Charlie" <Charlie@discussions.microsoft.com> wrote in message
> news:<97DA6951-68F7-4AE7-B398-86598A62B7BC@microsoft.com>...
> : > Without see all of your code it's a crap-shoot for me, but I'd guess
> that
> : > NameBuffer.Length is a Long (or Integer), and the arg position where
you
> are
> : > using it the function is expecting a string, not a Long (or Int).  Did
> you
> : > mean to use NameBuffer.Name?  Or just NameBuffer or something like
that?
> : >
> : > P.S. if you ever get tired of typing all those dollar signs and
> ampersands
> : > you might want to learn to Dim your variables instead!
> : >
> : >
> : > "boki" wrote:
> : >
> : > > Dear All,
> : > >
> : > >  I meet a problem when I compile my USB code, and I get this error
> : > > message
> : > >
> : > > ============================
> : > > Compile error:
> : > > ByRef argument type mismatch
> : > > ============================
> : > >
> : > > This problem happen at
> : > >
> : > >  ========================================
==========
> : > >   Function GetNameOf$(DeviceName$, DeviceHandle&, API_ID&)
> : > > ....
> : > > Status& = DeviceIoControl(DeviceHandle&, API_ID&, 0, 0,
> : > > NameBuffer.Length, 260, BytesReturned&, 0)
> : > >
> : > > ^^^^^^
> : > >                                   cursor stops at at "Length"
> : > > ....
> : > > ....
> : > >  ========================================
==========
> : > >
> : > > It is the problem "ByRef argument type mismatch"
> : > >
> : > > Set ByValue?
> : > >
> : > >
> : > > Best regards,
> : > > Boki.
> : > >
>



Report this thread to moderator Post Follow-up to this message
Old Post
Boki
09-30-04 09:44 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Visual Basic archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:40 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.