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




What goes wrong ?
Johan Loos
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

what so wrong with combo1.additem b ?
the easiest and the safest...
 b ="Johan" & Chr(0)
instead and see if it helps.
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...
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

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

JohanlAuthor Commented:
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 ?
And you have also added a ByVal in front of lParam? Svensk?
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)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.