?
Solved

Convert VBC code to C#

Posted on 2013-02-04
4
Medium Priority
?
228 Views
Last Modified: 2013-03-04
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
Comment
Question by:fjkilken
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 25

Expert Comment

by:SStory
ID: 38855182
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
 

Author Comment

by:fjkilken
ID: 38856096
doesn't look like that will work - "LoadPicture" method is not recognised
0
 
LVL 25

Accepted Solution

by:
SStory earned 1000 total points
ID: 38856194
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
 

Author Comment

by:fjkilken
ID: 38856245
thanks,
let me take a look at incorporating that tomorrow
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

800 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