I created a module to work with INI files and compiled it to a DLL file.
Then when I try using one of the functions, it tells me that the function is
not defined. I even put it inside a namespace so that I could import it.
I was hoping to write my functions so that they'd be available the same as
functions from system.data namespaces and the like are available. Is this
not possible?
TIA
--
Don
'Here is the module file. Note: I only added the namespace when
'I got the error message that writeINI was not declared.
Imports System
Imports Microsoft.VisualBasic
Namespace INIFiles
Module INIFiles
Declare Function GetPrivateProfileString Lib "kernel32" Alias
"GetPrivateProfileStringA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As String, _
ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Integer, _
ByVal lpFileName As String) As Integer
Declare Function WritePrivateProfileString Lib "kernel32" Alias _
"WritePrivateProfileStringA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As String, _
ByVal lpString As String, _
ByVal lpFileName As String) As Integer
'Store the location of the INI file
Public Function GetINI(ByVal sINIFile As String, ByVal sSection As String,
ByVal sKey _
As String, ByVal sDefault As String) As String
Dim sTemp As String = Space(255)
Dim nLength As Integer
nLength = GetPrivateProfileString(sSection, sKey, sDefault, sTemp, _
255, sINIFile)
Return sTemp.Substring(0, nLength)
End Function
Public Sub writeINI(ByVal sINIFile As String, ByVal sSection As String,
ByVal sKey _
As String, ByVal sValue As String)
'Remove CR/LF characters
sValue = sValue.Replace(vbCr, vbNullChar)
sValue = sValue.Replace(vbLf, vbNullChar)
If sValue = "" Then
sValue = vbNullString
End If
'Write information to INI file
WritePrivateProfileString(sSection, sKey, sValue, sINIFile)
End Sub
End Module
End Namespace 11 1342
Hi,
When you make a reference to a Dll file it allows you to use its
classes not its modules.
Ken
-------------------
"Don" <No****@nothanks.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... I created a module to work with INI files and compiled it to a DLL file. Then when I try using one of the functions, it tells me that the function is not defined. I even put it inside a namespace so that I could import it.
I was hoping to write my functions so that they'd be available the same as functions from system.data namespaces and the like are available. Is this not possible?
TIA
--
Don
'Here is the module file. Note: I only added the namespace when 'I got the error message that writeINI was not declared. Imports System Imports Microsoft.VisualBasic Namespace INIFiles Module INIFiles
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" _ (ByVal lpApplicationName As String, _ ByVal lpKeyName As String, _ ByVal lpDefault As String, _ ByVal lpReturnedString As String, _ ByVal nSize As Integer, _ ByVal lpFileName As String) As Integer
Declare Function WritePrivateProfileString Lib "kernel32" Alias _ "WritePrivateProfileStringA" _ (ByVal lpApplicationName As String, _ ByVal lpKeyName As String, _ ByVal lpString As String, _ ByVal lpFileName As String) As Integer 'Store the location of the INI file Public Function GetINI(ByVal sINIFile As String, ByVal sSection As String, ByVal sKey _ As String, ByVal sDefault As String) As String Dim sTemp As String = Space(255) Dim nLength As Integer
nLength = GetPrivateProfileString(sSection, sKey, sDefault, sTemp, _ 255, sINIFile) Return sTemp.Substring(0, nLength) End Function Public Sub writeINI(ByVal sINIFile As String, ByVal sSection As String, ByVal sKey _ As String, ByVal sValue As String) 'Remove CR/LF characters sValue = sValue.Replace(vbCr, vbNullChar) sValue = sValue.Replace(vbLf, vbNullChar) If sValue = "" Then sValue = vbNullString End If 'Write information to INI file WritePrivateProfileString(sSection, sKey, sValue, sINIFile) End Sub End Module End Namespace
* "Don" <No****@nothanks.com> scripsit: I created a module to work with INI files and compiled it to a DLL file. Then when I try using one of the functions, it tells me that the function is not defined. I even put it inside a namespace so that I could import it.
I was hoping to write my functions so that they'd be available the same as functions from system.data namespaces and the like are available. Is this not possible?
Add a 'Public' in front of the 'Module'.
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
So it sounds like I need to define it as a class with a methods to "get" and
"write"?
Thanks.!
--
Don
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uB**************@TK2MSFTNGP10.phx.gbl... Hi,
When you make a reference to a Dll file it allows you to use its classes not its modules.
Ken ------------------- "Don" <No****@nothanks.com> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...I created a module to work with INI files and compiled it to a DLL file. Then when I try using one of the functions, it tells me that the
function is not defined. I even put it inside a namespace so that I could import
it. I was hoping to write my functions so that they'd be available the same
as functions from system.data namespaces and the like are available. Is
this not possible?
TIA
--
Don
'Here is the module file. Note: I only added the namespace when 'I got the error message that writeINI was not declared. Imports System Imports Microsoft.VisualBasic Namespace INIFiles Module INIFiles
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" _ (ByVal lpApplicationName As String, _ ByVal lpKeyName As String, _ ByVal lpDefault As String, _ ByVal lpReturnedString As String, _ ByVal nSize As Integer, _ ByVal lpFileName As String) As Integer
Declare Function WritePrivateProfileString Lib "kernel32" Alias _ "WritePrivateProfileStringA" _ (ByVal lpApplicationName As String, _ ByVal lpKeyName As String, _ ByVal lpString As String, _ ByVal lpFileName As String) As Integer 'Store the location of the INI file Public Function GetINI(ByVal sINIFile As String, ByVal sSection As String, ByVal sKey _ As String, ByVal sDefault As String) As String Dim sTemp As String = Space(255) Dim nLength As Integer
nLength = GetPrivateProfileString(sSection, sKey, sDefault, sTemp, _ 255, sINIFile) Return sTemp.Substring(0, nLength) End Function Public Sub writeINI(ByVal sINIFile As String, ByVal sSection As
String, ByVal sKey _ As String, ByVal sValue As String) 'Remove CR/LF characters sValue = sValue.Replace(vbCr, vbNullChar) sValue = sValue.Replace(vbLf, vbNullChar) If sValue = "" Then sValue = vbNullString End If 'Write information to INI file WritePrivateProfileString(sSection, sKey, sValue, sINIFile) End Sub End Module End Namespace
* "Ken Tucker [MVP]" <vb***@bellsouth.net> scripsit: When you make a reference to a Dll file it allows you to use its classes not its modules.
Are you really sure about that? It works fine for me...
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
> Add a 'Public' in front of the 'Module'.
So why didn't you arrest Tucker or Don for including the entire post?
* "Don" <No****@nothanks.com> scripsit: So it sounds like I need to define it as a class with a methods to "get" and "write"?
Did you try it with 'Public Module...'? It works for me.
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
* "Peace" <Its the end of the world as we know it@here.com> scripsit: Add a 'Public' in front of the 'Module'.
So why didn't you arrest Tucker or Don for including the entire post?
Because the post you quoted was 48 KB and took some seconds to
download. That's really annoying, even if there is only one interesting
sentence in the post.
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Hi,
I stand corrected.
Ken
---------------
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:el**************@TK2MSFTNGP11.phx.gbl... * "Ken Tucker [MVP]" <vb***@bellsouth.net> scripsit: When you make a reference to a Dll file it allows you to use its classes not its modules.
Are you really sure about that? It works fine for me...
-- Herfried K. Wagner [MVP] <http://www.mvps.org/dotnet>
* "Ken Tucker [MVP]" <vb***@bellsouth.net> scripsit: I stand corrected.
:-)
As mentioned, it works, but it's not "recommended", especially when
designing a reusable component. I would prefer something like that:
<http://www.mentalis.org/soft/class.qpx?id=6>
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Remember that in .NET, modules are nothing more than classes whose members
are automatically Shared.
-Rob Teixeira [MVP]
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uB**************@TK2MSFTNGP10.phx.gbl... Hi,
When you make a reference to a Dll file it allows you to use its classes not its modules.
Ken
Herfried,
No--I hadn't read your post at the time that I replied to Ken's message.
I'll try Public Module.
--
Don
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl... * "Don" <No****@nothanks.com> scripsit: So it sounds like I need to define it as a class with a methods to "get"
and "write"?
Did you try it with 'Public Module...'? It works for me.
-- Herfried K. Wagner [MVP] <http://www.mvps.org/dotnet> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Erwin Moller |
last post by:
Hi group,
I have an includefile that I (ahum) include in many scripts.
It contains only functions I need now and then.
Now I was wondering how things work behind the scenes.
Is the whole...
|
by: Nolan Martin |
last post by:
is a static functions address constant?
ie..
static void func();
write_to_file(&func);
Restart program...
static void func();
void (*funcPtr) ();
|
by: Srini |
last post by:
Hello,
Rules for inline functions say that they have to be defined in the same
compilation unit as their declarations. For class member functions this
means that the inline member functions must...
|
by: cwdjrxyz |
last post by:
Javascript has a very small math function list. However there is no
reason that this list can not be extended greatly. Speed is not an
issue, unless you nest complicated calculations several levels...
|
by: Tim ffitch |
last post by:
Hi
I have created a VB dll file that contains common functions I use
across various projects in VB, Access and Excel. Rather than have to
code the functions in each I decided to use the dll...
|
by: John Goche |
last post by:
Hello,
I have been going through several header source files which define
classes with inline functions. In the case where the inline functions
are not defined in place, the inline functions...
|
by: hqprog |
last post by:
Having search extensively I've learned the two functions timegm and gmtime_r though in the GNU standard C library extend the ISO standard.
I need to use these two functions in myprog.c (on pc - ...
|
by: none |
last post by:
Hi,
I am wondering if anyone has some insight into a way to get the names of
the functions that are defined in a C header file.
What I am trying to do is develop tests for a large amount of C...
|
by: Bo Berglund |
last post by:
I have defined a few functions in a file, let's say it is called
functions.cpp. There are no objects involved, these are pure simple
functions.
In my test application I want to call this...
|
by: nicolas.sitbon |
last post by:
Hi everybody, in a french C book, the author says that only {fgetc,
getc, getchar, fgetwc, getwc, getwchar, fgets, gets, fgetws, getws,
fputc, putc, putchar, fputwc, putwc, putwchar, fputs, puts,...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
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...
|
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...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
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)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
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
|
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...
| |