Solved

CB_INSERTSTRING

Posted on 1997-08-11
7
514 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
LINQ return type for nested group query 6 71
Problem to skip loop 6 55
vb6 connector to mongodb 2 50
How to Add / Edit Windows Menu 4 52
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now