473,322 Members | 1,522 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,322 software developers and data experts.

vb.net dll that can be called by ms access 2003 - help

I created a dll in vb.net to calclulate the height of a block fo text as
follows:

Imports System.Drawing
Imports System.Math

Public Class DlnpFntCalcs

Public Function GetTextHeight(ByVal sNoticeText As String, ByVal
sFontName As String, ByVal dFontSize As Double, ByVal dClipWidth As Double)
As Double

Dim gr As Graphics = Graphics.FromHwnd(IntPtr.Zero)
Dim dFactor As Double = gr.DpiX / 100 '0.96 '0.96
'Pixel/HundredsOfInch

Dim fnt As New Font(sFontName, dFontSize, FontStyle.Regular,
GraphicsUnit.Point)

Dim size As SizeF = gr.MeasureString(sNoticeText, fnt, dClipWidth *
dFactor, StringFormat.GenericTypographic)
Return Round((size.Height / dFactor) / 100, 2)

End Function

End Class
I'm not registering it. It's currently being called by a vb.net exe I also
created and everything runs fine so far.

However, I also need to call the above function from an ms access routine.
From hunting around online I know that I need to do something with com. All
of this is very very new to me. I am not familiar with much of this area of
programming. I found this:
http://dsmyth.blogspot.com/2006/03/c...vba-using.html
which was a little helpful but a lot of the terminology is new to me and the
examples are very vague. I found a couple other things that helped me out a
bit but I still feel pretty far from the goal. I have no idea what to do to
the above to be able to call it from vba. I should mention that I would
rather not have to register the dll. I'm not doign that now for the current
setup and it's just fine. I don't have much say in this part of it. I'm ok
with hard coding the dll's path in the vba code.

Any help would be greatly apprciated.

Thanks,

Keith
Aug 21 '08 #1
1 1221
On Thu, 21 Aug 2008 12:35:02 -0400, "Keith G Hicks" <kr*@comcast.netwrote:

¤ I created a dll in vb.net to calclulate the height of a block fo text as
¤ follows:
¤
¤ Imports System.Drawing
¤ Imports System.Math
¤
¤ Public Class DlnpFntCalcs
¤
¤ Public Function GetTextHeight(ByVal sNoticeText As String, ByVal
¤ sFontName As String, ByVal dFontSize As Double, ByVal dClipWidth As Double)
¤ As Double
¤
¤ Dim gr As Graphics = Graphics.FromHwnd(IntPtr.Zero)
¤ Dim dFactor As Double = gr.DpiX / 100 '0.96 '0.96
¤ 'Pixel/HundredsOfInch
¤
¤ Dim fnt As New Font(sFontName, dFontSize, FontStyle.Regular,
¤ GraphicsUnit.Point)
¤
¤ Dim size As SizeF = gr.MeasureString(sNoticeText, fnt, dClipWidth *
¤ dFactor, StringFormat.GenericTypographic)
¤ Return Round((size.Height / dFactor) / 100, 2)
¤
¤ End Function
¤
¤ End Class
¤
¤
¤ I'm not registering it. It's currently being called by a vb.net exe I also
¤ created and everything runs fine so far.
¤
¤ However, I also need to call the above function from an ms access routine.
¤ From hunting around online I know that I need to do something with com. All
¤ of this is very very new to me. I am not familiar with much of this area of
¤ programming. I found this:
¤ http://dsmyth.blogspot.com/2006/03/c...vba-using.html
¤ which was a little helpful but a lot of the terminology is new to me and the
¤ examples are very vague. I found a couple other things that helped me out a
¤ bit but I still feel pretty far from the goal. I have no idea what to do to
¤ the above to be able to call it from vba. I should mention that I would
¤ rather not have to register the dll. I'm not doign that now for the current
¤ setup and it's just fine. I don't have much say in this part of it. I'm ok
¤ with hard coding the dll's path in the vba code.
¤
¤ Any help would be greatly apprciated.
¤
¤ Thanks,
¤
¤ Keith
¤

Yes, you need to register the component for COM interop because that is what Access understands.
Access can't communicate directly with managed code libraries. Use the Regasm utility to do this:

http://support.microsoft.com/kb/317535
Paul
~~~~
Microsoft MVP (Visual Basic)
Aug 22 '08 #2

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

Similar topics

11
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows...
2
by: BT Openworld | last post by:
I have just had to upgrade to Access 2003 as Access 97 EMail (SendObject) doesn't work when loaded on Windows XP. I'm finding my way around Access 2003 but my biggest problem is getting...
13
by: Noesis Strategy | last post by:
When I ordered my new laptop, Sony didn't offer Access 2003 in its bundles. Recently, I have begun to design Access databases using an copy of Access 2002 from my previous laptop. It works fine,...
7
by: Wayne Aprato | last post by:
I have several Access 2003 mde databases. When I try to open them in Access 2002 I get the following error: "The Visual Basic for Applications project in the database is corrupt." ...
3
by: Stickleback | last post by:
Morning All I have been developing and deploying with Office 2000 for about 3 years, mainly Access based programs and although I have gotten used to it's quirks, I am starting to feel that I...
28
by: Neil Ginsberg | last post by:
I have a client who is using Access 2002/2000 (the database itself is written in 2000), and is considering migrating to Access 2003. Any recommendations on whether Access 2003 is worth the migrate,...
10
by: Lauren Wilson | last post by:
Ok I have searched the MS website for info on this. I am totally confused. If I want to deploy an Access 2003 app and allow my users to run it using Access 2003 Runtime, where do I get the...
52
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server...
7
by: torus | last post by:
Is the aspnet account called "aspnet" for all non-English versions of Windows and IIS?
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
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.