|
Hello,
I need to pass an array of strings to a COM object implemented in VB. The Interop interface wants a ref System.Array. How can I convert my String[] to this format in the fastest way possible?
Rickard
|
|
|
|
|
Its already an array:
string[] strs = "a d g v g r d".Split(' ');
Array a = strs;
Mazy
"Improvisation is the touchstone of wit." - Molière
|
|
|
|
|
Take a look at this post. I think it solves your problem.
|
|
|
|
|
I want to open a DAO Recordset
Database tempDB;
Recordset rstbl;
rstbl = tempDB.OpenRecordset("SELECT Name FROM myTblNames", DAO.RecordsetTypeEnum.dbOpenTable, DAO.RecordsetOptionEnum.dbReadOnly , DAO.LockTypeEnum.dbPessimistic );
Error is Invalid argument
|
|
|
|
|
Why are you using DAO? First of all, it was superceeded long ago by ADO. And since this is the C# forum, I can only assume you're using C#. So why aren't you using ADO.NET? It's a hell of a lot easier in .NET applications and has many benefits over plain ADO (like easy parameterized queries, data adapters, and more).
You can find more information about ADO.NET in the .NET Framework SDK: Accessing Data using ADO.NET[^]. There's also several technical articles in MSDN with examples: ADO.NET[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
If taken a deep look into this hooking article: http://www.codeproject.com/csharp/NetWin32Hooks.asp?target=hook[^]. I had a problem with creating a global hook. The problem with creating a global hook, as some of you might know, is that the hook proc must reside in a seperate library so that it can be loading into all the running processes on the system. The author of the article above has testing just that with a .NET library and claims that it just doesn't work. I came up with a solution that I'm very close to finishing.
Basically I created a C++ library that implements all the hooking and exposes the functions so I can call them. For the .NET application to be able to get the events I resend them to the HWND that is passes when the hook is first installed. I can get the hook to work without a hitch if I call it from another C++ test application. However when I use P/Invoke to call the install function the hook isn't installed globally like expected but only hooks messages in the current thread. (In the C++ test application the hook works globally without a hitch) What am I doing wrong in this case? What is the right way to call the install function? If I can't get this to work I'll have to fall back to creating a C++ exe that will install the hook and initialize the HWND to resend events to.
|
|
|
|
|
Sounds like you're either P/Invoking the method wrong, or not passing the right parameter. Some code fragments (such as the P/Invoked method and the calling method) would help. Otherwise, you're not providing any information with which we can help you. Simply saying "it doesn't work" helps none.
Besides, you'd be better off asking this in the forum for that article, though asking here isn't exactly wrong (just that your question is specific to that article).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I know what are interfaces and what is the logic behind them, but I've never used them practically in any project.
Now I actually want to start incorporating them in my programms practically anc actually in a reasonable way.
I just want to know why should I use them instead of simply using classes? How are they useful when releasing new versions of our products?
Can you please provide me any link, where I can study and learn more about them? notice: practically
Regards!
|
|
|
|
|
I give you some point, you can't inherit from two class in C# but you can inherit from one class and as many as interface you waqnt. Is that enough reason forusing them in OOP world?
Mazy
"Improvisation is the touchstone of wit." - Molière
|
|
|
|
|
So, why interfaces are widely used in VC++, while it is possible to do multiple inheriting there?
|
|
|
|
|
They're great for writing plugins
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
Support Bone
It's a weird Life
|
|
|
|
|
|
- Interfaces lets you make multiple inherance.
The best examples are IList,ICollection,IEnumerate from the System.Collections namespace.
- Interfaces makes you focus on design before starting to actually do any coding. Ok, an example.
Consider you need to develop a product that manages customers, products and orders (classic example). Note that when starting to design the product, you do not know "implementation" details like how the data will be stored, etc...
The problem is sufficiently simple we don't have to go through UML and stuff but we can use interfaces to defines the relationships between the objects
public interface ICustomer
{
string Name {get;}
}
public interface IProduct
{
string Name {get;}
}
public interface IOrder
{
ICustomer Customer {get;}
IProduct Product {get;}
int Quantity {get;}
}
Here you can see the relationships between ICustomer, IProduct and IOrder. It is important to note that you have not written any "line of code" yet. You have just defined the objects. After that, you can implement the interface for database data, XMl file etc...
:=)
Jonathan de Halleux.
www.dotnetwiki.org
|
|
|
|
|
there's a couple reasons I use an interface. one of the biggest is so that I can write a function that can handle a generic reference of a class
here's an example I used it for
I created an ILookupTable interface that had methods like
Add(), Edit(), Delete(), SortUp(), SortDown() etc.
and then created several classes that implmented this interface
StateLookupTable,
TelephoneTypeLookupTable,
AddressTypeLookupTable
From there I could create one GUI that handled maintaining my lookup tables. When I needed to pass a class as a parameter, I would have a call like: public void MyCall(ILookupTable table)
and I knew I could call all of the properties and methods in that interface without actually having to know which particular class I was working with.
|
|
|
|
|
I have a two formed application in C#. I need to know how to get an integer from the initial form, to the second one.
|
|
|
|
|
What is the desired behavior of the two forms, i.e., what order will they be displayed, will the both be open at the same time, should one disappear...
Anyway, you might try passing the value from the first form to the constructor of the new form.
|
|
|
|
|
|
Something like this:
namespace FormConstructorParam
{
public class OverloadedConstructor : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
private int _value;
public OverloadedConstructor()
{
InitializeComponent();
}
public OverloadedConstructor(int someValue)
{
InitializeComponent();
_value = someValue;
}
}
}
then, when you create the instance of the form, you do this:
OverloadedConstructor oneForm = new OverloadedConstructor(1);
or this:
OverloadedConstructor anotherForm = new OverloadedConstructor();
|
|
|
|
|
The value could also be stored in a field or a property of either one or both of the forms...
|
|
|
|
|
Follow steps below:
1- Define a public or internal property inside your initial form(source class), which holds the integer value to send.
2- Define an overloaded constructor for the second form(destination class), which accepts an instance of the first form(i.e. Form1) as input parameter.
3- When instanciating the destination class(Form2), pass this keyword as input parameter to its constructor .
4- In destination class's constructor you have access the sourcr class's property, through this.PropertyName .
I hope this helps.
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
I'm sorry, i'm fairly new to this, could you give me an example?
|
|
|
|
|
I want to write a console application, Which will convert arabic numbers to roman.
But the problem is in roman 5000,10000 etc will be represented as V and a "-" symbol upon V..but i dont how to get these characters please let me know how to write a string a "-" upon them.
Please note that this is for console application
Its very urgent
|
|
|
|
|
Sounds like a class assignment for a computer science class...
GetOn&GetGoing wrote:
5000,10000 etc will be represented as V and a "-" symbol upon V
What do you mean, the fact that the roman numeral for five is a V with exaggerated serifs?
|
|
|
|
|
Ya i got it...
But how you will represnt 5000 you cant represent with "MMMMM", you should represnt as V and a "-" on that, i dont know how to print this kind of special characters in console application.
|
|
|
|
|
Ok, so a horizontal line over the roman numeral V is supposed to represent the fact that the number is multiplied by 1000. I think that that usage isn't really in vogue any more, but if it is necessary, how about writing an underscore ("_") on the line above the value?
|
|
|
|