Mixing VB & Csharp
Paul Witmond
Hi,I'm trying to create a basic function for getting the filename of a selected file.
This function is working in C
public void ReadFileName()
{
SwissAddonFramework.Utils.Windows.OpenFileDialog ofd = new SwissAddonFramework.Utils.Windows.OpenFileDialog();
ofd.Filter = "Excel files (*.xls)|*.xls|All files (*.*)|*.*";
ofd.FileSetEvent += new SwissAddonFramework.Utils.Windows.OpenFileDialog.FileSetHandler(delegate(string filename )
{
// ** do something with the filename
});
ofd.ShowDialog();
return;
}
My problems are (yes 2 problems !)
1) I can use this function only when calling from a C-Shap based function. When creating a function button VB based I have an error, when calling from a CS based call it's working
2) How can I return the filename to the calling functio
Paolo Manfrin
Hi Paul,I assume you created the ReadFileName() function in the Extended Code.
It is not possible to mix C# code and Visual Basic code in customize.
That means that you have to create the same function in Extended Code selecting from the drop down list of Extended Code, "Visual Basic" as scripting language.
Extended Code for C# works with C# rules
Extended Code for Visual Basic works with Visual Basic rules
Kind Regards,
paolo
Paul Witmond
Hi Paolo,You are 100% correct !
I didn't know that C code wasn't usable in VB code.
Do you have a translation for the openfiledialog ?
Thanks,
Paul
Paolo Manfrin
Hi Paul, you need to add a reference to the microsoft library (check attachment)Then without the using directive you could also use it like:
Microsoft.Office.Interop.Excel.Application oExcel = new Microsoft.Office.Interop.Excel.ApplicationClass();
and so on...
Kind Regards,
Paolo
Attachment
[url=http://www.coresystems.ch/wp-content/../wp-content/forum-image-uploads/paolo-manfrin/ExcelReference.jpg]ExcelReference.jpg[/url]
Paul Witmond
Hi Paolo,Where do I find that screen ?
Tnx
Paul
Paolo Manfrin
Hi Paul,It's explained in the official documentation
http://msdn.microsoft.com/en-us/library/wkze6zky.aspx
Kind Regards,
paolo
Paul Witmond
Hi Paolo,Thans for the very quick response.
Grtz
Paul
0
Please sign in to leave a comment.
Comments
0 comments