Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / August 2004



Tip: Looking for answers? Try searching our database.

Creating reusable functions in vb .net.  And how to call?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Todd Tuskey - 29 Aug 2004 01:49 GMT
Below is a very simple application, just to see if I can do this.

What I want to do is put the two functions, TimesTwo and TimesThree in one
common callable component (a .dll I suppose).
I've created a dll (at least the build went ok) containing those two
functions enclosed in a CLASS, but can't figure out how to call it.

Thanks!
Public Class Form1

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
     MsgBox(TimesTwo(12) & "/" & TimesThree(12))
  End Sub

  Public Function TimesTwo(ByVal numIn As Integer) As Integer
     TimesTwo = numIn * 2
  End Function

  Public Function TimesThree(ByVal numIn As Integer) As Integer
     TimesThree = numIn * 3
  End Function
End Class
Todd Tuskey - 29 Aug 2004 01:52 GMT
Actually it may be important to note that I'm working with VB .net 2005 beta
(don't know how much is different fron 2003 but this is my first foray into
any .net).

> Below is a very simple application, just to see if I can do this.
>
[quoted text clipped - 19 lines]
>    End Function
> End Class
Todd Tuskey - 29 Aug 2004 05:32 GMT
I got it to run, but is this "the" way to get your dlls to work?
I compiled the DLL as a class.
Then I imported the class into my project (project->add reference).
Then I set an variable equal to a new instance of my class.  I could then
accesss all of the functions with the syntax form x =
ClassVariable.ClassFunction(x,y)

> Actually it may be important to note that I'm working with VB .net 2005 beta
> (don't know how much is different fron 2003 but this is my first foray into
[quoted text clipped - 23 lines]
> >    End Function
> > End Class
Ken Halter - 30 Aug 2004 15:19 GMT
> I got it to run, but is this "the" way to get your dlls to work?
> I compiled the DLL as a class.
> Then I imported the class into my project (project->add reference).
> Then I set an variable equal to a new instance of my class.  I could then
> accesss all of the functions with the syntax form x =
> ClassVariable.ClassFunction(x,y)

3 strikes... yer out!. Try posting your question in a VB.Net group. This
group has nothing to do with .Net. All .Net groups have "vsnet" or
"dotnet" in their names.

Signature

Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep all discussions in the groups..

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.