473,324 Members | 2,581 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

dll create conflict

Ron
Hello,

I am trying to create a C# test dll to try out in an MS
Access mdb application. I open up a session of vs2003,
select C#/Class Library. Here is my code:

---------------------------------------------
using System;

public class firstDll
{
public static int myFirstDll()
{
int n = 5;
return n;
}
}
-----------------------------------------------

Before I build the dll I go to Project (called "testdll")
properties and select 'Register for Com Interop' = True.
Then I build the dll. Then I create a reference to the
testdll.tlb file in MS Access. But when I try to use the
dll it doesn't work. Here is how I invoke it in the
Access mdb

------------------------------------
Sub testOutDll()
Dim fd As testdll.firstDll
Set fd = New testdll.firstDll
Debug.Print fd.myFirstDll
End Sub
------------------------------------

I am able to see the intellisense dropdown for

Dim fd As testdll.firstDll
Set fd = New testdll.firstDll

But I don't get the intellisense dropdown for

fd.myFirstDll

The idea is that I would see "5" in the debug window. Can
anyone see what I am doing incorrectly here?

Thanks,
Ron
Nov 16 '05 #1
3 1513
Ron
I removed the static in

public static int myFirstDll()
....

Now the dll seems to work, but even though I get the
dropdowns for

Dim fd As New testdll.firstDll

I don't get the dropdown for

fd.myFirstDll

Any suggestions appreciated how I can make the dropdowns
work for the property.
-----Original Message-----
Hello,

I am trying to create a C# test dll to try out in an MS
Access mdb application. I open up a session of vs2003,
select C#/Class Library. Here is my code:

---------------------------------------------
using System;

public class firstDll
{
public static int myFirstDll()
{
int n = 5;
return n;
}
}
-----------------------------------------------

Before I build the dll I go to Project (called "testdll")
properties and select 'Register for Com Interop' = True.
Then I build the dll. Then I create a reference to the
testdll.tlb file in MS Access. But when I try to use the
dll it doesn't work. Here is how I invoke it in the
Access mdb

------------------------------------
Sub testOutDll()
Dim fd As testdll.firstDll
Set fd = New testdll.firstDll
Debug.Print fd.myFirstDll
End Sub
------------------------------------

I am able to see the intellisense dropdown for

Dim fd As testdll.firstDll
Set fd = New testdll.firstDll

But I don't get the intellisense dropdown for

fd.myFirstDll

The idea is that I would see "5" in the debug window. Cananyone see what I am doing incorrectly here?

Thanks,
Ron
.

Nov 16 '05 #2

"Ron" <an*******@discussions.microsoft.com> wrote in message
news:26****************************@phx.gbl...
I removed the static in

public static int myFirstDll()
...

Now the dll seems to work, but even though I get the
dropdowns for

Dim fd As New testdll.firstDll

I don't get the dropdown for

fd.myFirstDll

Any suggestions appreciated how I can make the dropdowns
work for the property.


Hrm, you wouldn't see a method for a static method of a library because it's
static. You would, however, see the method if you tried
testdll.firstDll.myFirstDll because you are accessing it like it's static
(which it is). Example:

public class MyClass
{
private string mMyString;

public static int GetMyInteger()
{
return 1234;
}

public string GetMyString()
{
return mMyString
}

public MyClass(string MyString)
{
mMyString = MyString;
}
}

Now you can use the following:

MsgBox MyClass.GetMyInteger

Dim obj As MyClass

Set obj = New MyClass("Hello World!")
MsgBox obj.GetMyString
Set obj = Nothing
Hope this helps...

Mythran
Nov 16 '05 #3
Ron
Thanks, yes. This is very helpful.
-----Original Message-----

"Ron" <an*******@discussions.microsoft.com> wrote in messagenews:26****************************@phx.gbl...
I removed the static in

public static int myFirstDll()
...

Now the dll seems to work, but even though I get the
dropdowns for

Dim fd As New testdll.firstDll

I don't get the dropdown for

fd.myFirstDll

Any suggestions appreciated how I can make the dropdowns work for the property.

Hrm, you wouldn't see a method for a static method of a

library because it'sstatic. You would, however, see the method if you tried
testdll.firstDll.myFirstDll because you are accessing it like it's static(which it is). Example:

public class MyClass
{
private string mMyString;

public static int GetMyInteger()
{
return 1234;
}

public string GetMyString()
{
return mMyString
}

public MyClass(string MyString)
{
mMyString = MyString;
}
}

Now you can use the following:

MsgBox MyClass.GetMyInteger

Dim obj As MyClass

Set obj = New MyClass("Hello World!")
MsgBox obj.GetMyString
Set obj = Nothing
Hope this helps...

Mythran
.

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Web Developer | last post by:
Hi, Question: Why is there an inherent conflict between uncompromising efficiency and portability in C++? Regards WD
0
by: VHR | last post by:
Hi, I apologize for posting this a second time, but no one replied from the other group where I posted it. I have a design master and 4 replicas that I have successfully synced on about 4-5...
0
by: vb | last post by:
Hi, Sorry, I am new to C#, so this can be a very simple question. I am using some of DevExpress components in my application.My References in the Solution(for DevExpress) are: DevExpress.Data;...
1
by: lorirobn | last post by:
Hi, I have a query that I have been using as a record source for a form with no problems. I just created a new "addnew" form, and added 20 records to the table with this form. The problem I...
11
by: raylopez99 | last post by:
Keep in mind this is my first compiled SQL program Stored Procedure (SP), copied from a book by Frasier Visual C++.NET in Visual Studio 2005 (Chap12). So far, so theory, except for one bug...
14
lotus18
by: lotus18 | last post by:
Hello World I have a problem in detecting the conflict schedule (Day and Time). Day 1. M 2. T 3. W 4. TH 5. F
14
lotus18
by: lotus18 | last post by:
Hello all I have these records on my Day Table for my complete database table please click here 1. M 2. T 3. W 4. TH 5. F 6. S
0
by: Bob Alston | last post by:
I have suddenly gotten several replication conflicts where in the winning conflict box, the following is shown: "This row contains data that violates a table or fields level validation rule that...
0
by: =?ISO-8859-1?Q?Gerhard_H=E4ring?= | last post by:
egbert wrote: No, it's just like every other database error - the command fails but the connection is left untouched. Sure, the successful ones ;-) FWIW, this restriction is not any...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.