Make dll that contain one function. Help Please.

R

Robert

Vb.Net Make dll that contain one function. Help Please.


I would like to call a function from different applications.
I think i have to make a dll.
I have Visual Basic.net 2003 Standard Edition, that teorically does
not make dll,
but pratically does.

I search vbc.exe and copy it to a new folder, in which i have the
following batch file

Make a New folder.
Search "vbc.exe" and Copy it to the new folder.
Make a new Batch file, whith the following code and name it
"Create_Dll.bat:

Create_Dll.bat
"vbc.exe" /target:library /out:My_dll
/reference:System.dll,System.Data.dll,System.Drawing.dll,System.Windows.Forms.dll,System.XML.dll
"My_Code.vb"
pause



Of course "My_Code.vb" contains the dll code.
I would like to put there a function i can call from any application.

Just as example there is a simple function by: Tom Harris at the
following address
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2553&lngWId=10
that removes unwanted chars.
using that function as example how would the code be in "My_Code.vb" ?


Can somebody help ?



Best Regards.

Robert.







Following the code by Tom Harris,
from http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2553&lngWId=10

//**************************************
//
// Name: Clean Unwanted Characters From
// a String
// Description:Function to clean all cha
// racters but A-Z, a-z, and 0123456789. Wh
// en I don't use Regular Expressions I use
// this function to put only the characters
// I want into a string. It is very useful
// for password generation. Look up the Dec
// number on an ASCII chart and use this fo
// r many things.
// By: Tom Harris
//
// Inputs:The string you want to remove
// unwanted characters from
//
// Returns:A String with only A-Z, a-z,
// and 0-9 charactes
//
// Assumes:You will need an ASCII chart
// to look up the DEC values associated wit
// h the ASCII character if you want to mod
// ify the specific chars stripped.
http://www.asciitable.com is a good resource.
//
//This code is copyrighted and has // limited warranties.Please
see http://
// www.Planet-Source-Code.com/vb/scripts/Sh
// owCode.asp?txtCodeId=2553&lngWId=10 //for details.
//**************************************
//

'Function to clean all characters but A-Z, a-z, and 0123456789
'When I don't use Regular Expressions I use this function to put
'only the characters I want into a string. It is very useful
'for password generation. Look up the Dec number on an ASCII
'chart and use this for many things.

Public Function CleanString(ByVal strDirty As String) As String

Dim strLen As String
Dim strCounter As Integer
Dim strClean As String

strLen = strDirty.Length
strClean = ""
For strCounter = 1 To strLen
Select Case Asc(Mid(strDirty, strCounter, 1))
Case 65 To 90 'A-Z
strClean = strClean & Mid(strDirty, strCounter, 1)
Case 97 To 122 'a-z
strClean = strClean & Mid(strDirty, strCounter, 1)
Case 48 To 57 ' 0123456789
strClean = strClean & Mid(strDirty, strCounter, 1)
Case Else
'All other characters are stripped out
End Select
Next

Return LCase(strClean)

End Function
 
S

Samuel R. Neff

The OOP way to do it would be to make the function a shared function
on some class and import the class's namespace in the calling code
(where the calls will be ClassName.FunctionName).

The VB6 way to do it would be to put the function inside a module and
then import the module in the calling code (calls will be just
FunctionName).

HTH,

Sam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top