468,765 Members | 1,729 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,765 developers. It's quick & easy.

Make dll that contain one function. Help Please.

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.Drawin g.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...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...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
Nov 21 '05 #1
1 1594

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

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by scottyman | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.