• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

Convert VBC code to C#

Hi
I have a small section of VBA code which I need to convert/rewrite in C#.
Basically the code specifies the count, name and location of images which are to be used in a gallery on a custom Excel Ribbon:

Sub getBSCGalleryItemImages(control As IRibbonControl, index As Integer, ByRef image)
    Set image = LoadPicture("//images/report_snapshot_" & index + 1 & ".jpg")
End Sub
Sub getBSCGalleryItemCount(control As IRibbonControl, ByRef count)
        count = 3
End Sub

Open in new window


Thanks for the help

Fergal
0
fjkilken
Asked:
fjkilken
  • 2
  • 2
1 Solution
 
SStoryCommented:
It would be something like the following:
void getBSCGalleryItemImages(IRibbonControl control,int Index, ref image) {

    image = LoadPicture("//images/report_snapshot_" + int.parse(index + 1) + ".jpg");

}

void getBSCGalleryItemCount(IRibbonControl control, ref count) {

        count = 3;

}

Open in new window


Per your code I didn't know what type variable count was or Image, so those may have to be added.
0
 
fjkilkenAuthor Commented:
doesn't look like that will work - "LoadPicture" method is not recognised
0
 
SStoryCommented:
OK.
You will need a

using System.Drawing;

at the top of the module in C#


String path="//images/report_snapshot_" + int.parse(index + 1) + ".jpg";
Image image1 = Image.FromFile(path);

Image.FromFile()
can load an image from a file.
0
 
fjkilkenAuthor Commented:
thanks,
let me take a look at incorporating that tomorrow
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now