Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.NET Interop with VB6 - Passing a picture

Status
Not open for further replies.

jester18

Programmer
Jan 23, 2002
8
GB
Please Help before i kill my machine (not realy but thats how i feel).

I have successfully created AND compiled AND referenced a new class in VB.NET, and created the counter program to use it in VB6, however this works fine if i pass a string but i want to pass a picture from VB6 to VB.NET.

Here is the snippit of code in VB.NET
--------------------------------------
Public Sub addimage(ByVal stdpic As stdole.StdPicture)

End Sub
--------------------------------------


Here is the snippet of code in VB6
--------------------------------------
Private Sub Command1_Click()
Dim o As ClassLibrary1.CCWClass
Set o = New ClassLibrary1.CCWClass
Dim i As StdPicture
Set i = LoadPicture("c:\test.bmp")
o.addimage (i)
End Sub
--------------------------------------

When i run it it generates an error :-
"Run-time error '5':

Invalid procedure call or argument"

Im sure its only because i havent passed the correct information.

Please help me.
Thanks.

P.S. i have only had VB.NET for a few days so please forgive me if there is a easy solution.

 
I have found a rather inadequate solution by using the windows clipboard.

VB6 Snippet
---------------------------------------
Private Sub Command1_Click()
Dim i As StdPicture
Set i = LoadPicture(List1.Text)

Dim clip As Clipboard
Set clip = Clipboard
clip.Clear
clip.SetData i, vbCFBitmap
ok = o.addimage
End Sub
---------------------------------------

VB.NET Snippet
---------------------------------------
Public Function addimage() As String
Dim icount As Integer
Dim bitmap1 As System.Drawing.Bitmap
icount = images.GetUpperBound(0)
icount = icount + 1

ReDim Preserve images(icount)

bitmap1 = Clipboard.GetDataObject.GetData( _
DataFormats.Bitmap, True)
images(icount) = bitmap1
addimage = icount.ToString
End Function
---------------------------------------

This is far from what i wanted to do but will be ok for now please post a reply if you can answer my origional question.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top