Building DLL's

  • Thread starter Thread starter Ian Henderson
  • Start date Start date
I

Ian Henderson

I have a function, originally written for use in Access97, which formats a
character string, according to the format prescribed in the code that calls
it. What this means is that if you run a string containing a Scottish
surname (such as McDonald) through the function, it will come out with the
correct letters converted to Uppercase. Also, it'll correctly format a UK
postal code, or UK telephone number, as dictated by the switch in the code.

Now, in Microsoft Access, the following code would be used:

For a character field to be formatted as a standard text string, the code
would read "sMyText = TextFormat(sMyText,"Text") "
For a character field to be formatted as a UK Postal Code, the code would
read "sMyText = TextFormat(sMyText,"Pcode")
For a character field to be formatted as a UK Phone Number, the code would
read "sMyText = TextFormat(sMyText,"Phone")

Now, I've successfully converted the TextFormat functions so that they
compile properly using VB.NET. However, I've got no way of testing that it
does exactly what it's supposed to do. I need to know the following:

1. How do I register the DLL so that it can be picked up by any
application that happens to need it
OR
Can I write code that will register the DLL before it runs it,
without causing a conflict if the DLL has already been registered.
2. How do I create a form, in a separate project, that can be used to
check whether the function is working properly?

I'd be really grateful if anyone can help me with this - it's been doing my
head in for about a week now.

Thanks in Advance


Ian Henderson
Database Developer and .NET Novice
 
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim str As String = "hello"

str = StrConv(str, vbProperCase)

MessageBox.Show(str)

End Sub
 
That works for the StrConv function. However, the StrConv function doesn't
handle Scottish surnames.

For example, if you pass "mcdonald" into StrConv, it will return it as
"Mcdonald". The function that I written will take the same input string (ie
"Mcdonald"), and pass it back as "McDonald". Also, it'll handle
double-barrelled surnames, such as Rhys-Jones, which StrConv would pass back
as "Rhys-jones".

Any ideas?

TIA


Ian Henderson
 
Ian,
I think that maybe the regex.replace will help you.

I would solve your problem just with an array, but I think the regex.replace
is better.

I never used it because I find making patterns always difficult.

But today someone send a link of his a tool to make those patterns
http://www.radsoftware.com.au/web/Products/

I hope this helps a little bit.
Cor
 
I tried that the other day. That approach has always worked for me in the
past, using VBA in Access97. However, if you try it in vb.NET, you get a
message telling you that it doesn't like it. The only way of doing it is as
previously described, by replacing the incoming string.

Thanks anyway.

Ian
 
Hello,

Steven Smith said:
mid(TargetString, start, count) = UCase(ReplacementSTring)
???

I think the problem is writing the algorithm that does the replacement for a
whole name.
 
Why dont you create a class for this conversion instead ?, if you really
want to create a DLL you will need to use C++ ( not sure if you can do this
in C# )
 
If that's the case, why does VB.NET give me the option to build components
and compile them as DLLs? Certainly the online help I've looked at talks
about using RegSrv32, but contains references to C++ code.

Ian
 
I'm not sure exactly where you are looking at Ian, but to the best of my
knowledge you cannot compile DLL's from Visual Basic.NET in the way you are
trying to. However, if you do generate a DLL from VC++, and want to call a
user function ( as you do ) from VB.NET then this is of course possible.

But, why go to all this bother when you can port your logic ( and I cant
think that its too complex ) to a VB class definition.

Probably not what you wanted to hear but . . .

Regards OHM
 
Back
Top