1

I wrote a library which has a function call that returns a System.Drawing.Bitmap. Everything works great and I can access it just fine from a C# WPF application. However, now I need to make it work with a VB 6 application and for the life of me I can`t get it to work. I have a VB6 picturebox (note: this could be changed to an image control if necessary; we just need the image to display on the screen somehow) Right now I have tried the following unsuccessfully:

Set Form1.PictureBox1.Image = myImage <-- This causes invalid use of property on 'Form1.PictureBox1.Image'

Form1.PictureBox1.Image = myImage <-- This causes invalid use of property on 'Form1.PictureBox1.Image'

Form1.PictureBox1.Picture = myImage <-- This cause 'type mismatch'

Help please! I don`t know VB at all let alone VB 6.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
TwinPrimesAreEz
  • 1,699
  • 1
  • 12
  • 16
  • Add the Set keyword to your first example and it should work, barring any issues with what's in myImage. – Eric Walker Nov 18 '15 at 16:45
  • Thanks for the suggestion but that doesn`t work (edited the question to reflect that). Any other control ideas? I`m not tied to a picture box. – TwinPrimesAreEz Nov 18 '15 at 16:58
  • 1
    This is just a thought... but VB6 probably doesn't use the System.Drawing.Bitmap for PictureBox, since that framework did not even exist when VB6 was designed. You may have to do an intermediary step, like have another method in your library that saves the image to disk, and then have the VB6 application load from disk. – vbnet3d Nov 18 '15 at 17:02
  • Ok, if adding Set didn't work, you'll need to compare what you've got in myImage to the data expected by the .Image property as vbnet3d suggested. – Eric Walker Nov 18 '15 at 17:12
  • Ok, thanks guys I may just have to pass the original byte array that composes the picture and then draw it that way (with PSet I believe) – TwinPrimesAreEz Nov 18 '15 at 17:18
  • 1
    You might also look at: http://stackoverflow.com/questions/6110337/convert-system-drawing-bitmap-to-stdole-stdpicture --- if you can simply convert it in your library, that will make your VB6 application more seamless. – vbnet3d Nov 18 '15 at 17:19

0 Answers0