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

x
?
Solved

API Call Requires Null

Posted on 2003-10-30
32
Medium Priority
?
335 Views
Last Modified: 2010-05-01
How do you send a null value to an API call in VB? Its got to be the same as if I were to type null in C++....  whenever I use VBnull it doesn't work, whenever I set a variant value to null that does work either.... Thanks
0
Comment
Question by:sk33v3
29 Comments
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 9655851
try vbNullString ?
0
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 9655855
Hi,

use vbNullPointer for long pointers
define

const NULL_STR_POINTER = &0;
and use for pointer to string that must be null.

-FA
0
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 9655865
Sorry

use vbNullString for string type. define NULL_LNG_PTR = &0 and use for long type.

-FA
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.

 
LVL 9

Author Comment

by:sk33v3
ID: 9655890
when I try to declare that null_lng_ptr it adds an O

Public Const NULL_LNG_PTR = &O0
0
 

Expert Comment

by:micask8
ID: 9655933
The O means that the number is octal number. If you need a hexadesimal number write &H0. I'm not sure if it really matters whether you use octal or hexadesimal number...
0
 
LVL 9

Author Comment

by:sk33v3
ID: 9655958
neither of the 2 work right, it doesn't return what the C++ equivalent of Null for a long is.
0
 
LVL 3

Expert Comment

by:gafoorgk
ID: 9655985
u can send api null as &0. like following;

SendMessage(<hwnd>, <message_code>, <wparam>, ByVal 0&)
0
 
LVL 9

Author Comment

by:sk33v3
ID: 9655992
what goes in the hwnd, message_code and wparam?
0
 
LVL 5

Expert Comment

by:fantasy1001
ID: 9656065
Normally, we use &0 as null for long.
For example, the SendMessage(me.hwnd, BN_CLICKED, 0&, 0&)
The hwnd can be any window handler for example

dim hwnd as object
hwnd = findwindow("classname", "windowcaption")

If the above cannot work, then try to change long to any like
Declare Function FindClose Lib "kernel32" Alias "FindClose" (ByVal hFindFile As Long) As Long
to
Declare Function FindClose Lib "kernel32" Alias "FindClose" (ByVal hFindFile As any) As Long

For all API reference:
http://www.mentalis.org/

Thanks,
~ fantasy ~
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 9656176
You can also try vbNull
0
 
LVL 1

Expert Comment

by:vkaushik
ID: 9656275
try with the null character ' '. In  VB use the returned value from Chr$(0) to create this null character
0
 
LVL 9

Expert Comment

by:_ys_
ID: 9656676
If your API declaration is for a string parameter and you want to pass null, I'm surprised that vbNullString doesn't do the job.

Another method is to rewrite the declare statement. e.g. FindWindow could be rewritten from

Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

to

Declare Function FindWindow Lib "user32" Alias "FindWindowA" (lpClassName As Long, ByVal lpWindowName As String) As Long

The second would allow for use of the 0& long constant just about everyone else has mentioned.

Dim hWnd As Long
hWnd = FindWindow (0&, "whatever")
0
 
LVL 9

Expert Comment

by:_ys_
ID: 9656677
Sorry, that sould've been ByVal

hWnd = FindWindow (ByVal 0&, "whatever")
0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 9656759
Your API function (SendMessage I take it) will work with 0& for long and vbNullString for string, as said. It's probably the message you're sending that's failing. Check the return value of the function to see.
0
 
LVL 1

Expert Comment

by:vkaushik
ID: 9656804
Yes it might be the message is failing
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9657219
sk33v3, what is the api function/declaration that you are using (in first)?
0
 
LVL 9

Author Comment

by:sk33v3
ID: 9659303
Well I can't give you the Actual DLL Call but I can make a mock up of what it looks like.

MyAPICall(LngHandle, TypeOfOption , NULL_LNG_PTR, NULL_LNG_PTR)

Any Ideas?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9659385
I don't want dll, just what declaration are you using.
Is it a standard dll that comes with Microsoft products?, if no, do you know if that dll accept callings from VB?, just remember that for dlls used by VB, they have to follow _stdcall calling convention.

0
 
LVL 9

Author Comment

by:sk33v3
ID: 9659634
Public Declare Function StartCommunication Lib "MyCom" (ByRef lpdwHandle As Long, ByVal dwPortType As Long, ByVal PortAddress As Long, lpbReserved As Long) As Long
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9660322
All parameters appears to just longs, so passing 0& as last parameter should be enought if it doesn't waits for a pointer to a function (like EnumChildWindows api in example)
0
 
LVL 9

Author Comment

by:sk33v3
ID: 9660849
well I was told the error I was getting from it was because I wasn't passing Null to it properly, All the examples they have are for C++ only and they use the null constant....
0
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 9661131
Could you post the C++ example used? You might need to pass a pointer to a buffered string which is null-terminated. Blind guess, however. Have no clue on how the function is supposed to handle it's parameters.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9664123
Please maintain your many old open questions:

1 09/19/2003 500 RealBasic  Unlocked Macintosh Programming
2 09/26/2003 500 Power point(PPT) to Quicktime(mov) Conve...  Unlocked Microsoft Office
3 10/12/2003 500 Print Screen  Unlocked Visual Basic
4 01/23/2003 50 Network Trouble shooting utility  Unlocked Networking
5 08/27/2003 250 PHP With IIS?  Unlocked Internet Information Server
6 10/06/2003 500 RB, What is wrong with this?  Unlocked Macintosh Programming
7 10/07/2003 250 Windows App to Mac App. Registry?  Unlocked Macintosh Programming

Thanks,
Anthony
0
 
LVL 9

Author Comment

by:sk33v3
ID: 9805295
Well what we ended up doing was making the Interface into the component in C++ and referencing it from VB.... That fixed it. I am going to request that this question be deleted. Thanks.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9805944
Thank you for taking care of your open questions.  However, I believe you overlooked this open question:
http://www.experts-exchange.com/Programming/Programming_Platforms/Mac_Prog/Q_20758795.html

In order to close this question, see the following:
Request a refund because you answered your own question (Refund/PAQ) http://www.experts-exchange.com/help/closing.jsp#4
Request a refund because no one answered your question (Delete) http://www.experts-exchange.com/help/closing.jsp#5

Thanks,
Anthony
0
 
LVL 28

Accepted Solution

by:
Ark earned 2000 total points
ID: 9970140
MyAPICall(LngHandle, TypeOfOption , ByVal 0&, ByVal 0&)

0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9972645
WOW!, THE BOY is back in town!!
Hi!
:)
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9972655
"Mr. Ark, ...welcome back, we...missed you"
0
 
LVL 28

Expert Comment

by:Ark
ID: 9976132
Hello Richie and all experts! Finally I've defend my PhD degree on wednesday and now I'm back :)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

834 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