Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CB_INSERTSTRING

Posted on 1997-08-11
7
Medium Priority
?
533 Views
Last Modified: 2008-03-06
All,

Why does it not work, I use VB 5.0, have one combo-box on my form and a command button. When I click on the button a string should be added to the combo (list) box.
But everytime I click 'rare' characters will be added such as |%ù but NOT the string, please help

The code :

Dim a&
Dim b as String

b=String$(255,Chr$(0))

b="Johan"

a=SendMessage(combo1.hWnd,CB_INSERTSTRING,-1,b)

What goes wrong ?
Regards
Johan Loos
jloos@glo.be
0
Comment
Question by:Johanl
7 Comments
 
LVL 2

Expert Comment

by:msiman
ID: 1430258
what so wrong with combo1.additem b ?
the easiest and the safest...
msiman
0
 
LVL 5

Expert Comment

by:y96andha
ID: 1430259
Try
 b ="Johan" & Chr(0)
instead and see if it helps.
0
 
LVL 2

Expert Comment

by:msiman
ID: 1430260
btw: the reason for your problem, is
(I guess...) that in the sendmessage API
the last parameter should be integer, and here,
b is a string...
MSIMAN
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:y96andha
ID: 1430261
I assume that you have declared the parameters for SendMessage like this:

Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long

0
 

Author Comment

by:Johanl
ID: 1430262
To y96andha : Does not work with chr$(0) at the end.

To msiman and y96andha : yes, my last param is a string . I used the declaration as y96andha say.

strange thing ?
0
 
LVL 5

Expert Comment

by:y96andha
ID: 1430263
And you have also added a ByVal in front of lParam? Svensk?
0
 
LVL 7

Accepted Solution

by:
tward earned 100 total points
ID: 1430264
The Following works just fine for me:

Private Const CB_INSERTSTRING = &H14A
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long

Dim a&
Dim b As String

b = String$(255, Chr$(0))

b = "Johan"

a = SendMessage(Combo1.hwnd, CB_INSERTSTRING, -1, b)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

916 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