-
I'm makeing a small program that edits an ini file, it works but the problem is that the ini file that I am editing's titles are formated like this: [ title ] unless I manualy chainge them to: [title] it doesn't work.
I have tryed: lpappname = " title " but it still doesn't work unless the format in the ini is [title]
TIA,
Alex
-
-
the program will only retrive information from the ini file if the titles in the ini are writen like this: [title] if they are writen as [ title ] I get an error mesage e.g.
[Joy]
allow_force_feedback=1
force_feedback_damping=150.000000
force_feedback_latency=0.025000
max_steering_torque=300.000000
but in the actual ini they are writen like this:
[ Joy ]
allow_force_feedback=1
force_feedback_damping=150.000000
force_feedback_latency=0.025000
max_steering_torque=300.000000
how do I specify that there will be spaces between the [ and the title in my VB code e.g.
lpappname = "joy"
lpappname = " joy " doesn't work
-
what's the code you use to get the content of the ini file, the api functions or you have made them on your own?
-
Use API functions. It is SO easy once you used the API.
I also had the same trouble.
-
yep I'm useing the API functions and it works fine apart from those bloudy spaces ;)
-
I do not use API when I can use plain VB code. Why don't you remove the punctation manually?
Quintonir
-
hmmm...that is interesting....
I had the problem with the spaces when I used plain VB code, but when I changed to API function the problem was gone.
I got the code snippet from a user here named Matthew Gates. Maybe he can direct you further.....he seems to be VERY knowlegable.
-
I have maualy edited it but I'm planning to distribute the program and I couldn't expect everyone else to do that. How could I use plain VB code to do the Same thing without over complicateing things?
-
Shall I state a self-made Replace() function?
-
If you are using VB6, you could use the REPLACE function to format these spaces :
Code:
Dim StrFile as String
StrFile = "C:\Name_Of_File.ini"
Replace "[ ", StrFile, "["
Replace " ]", StrFile, "]"
This will only work if there's one space between the bracket & the word, and I am 99% sure that this is only for VB6. But, it might be able to help you, use the above before you retrieve the ini file information. :)
-
1 Attachment(s)
I use API and don't have this problem
se my module
-
I can't seem to get that module working, could you post some sample code?
this is the module I was useing:
Code:
Public Declare Function WritePrivateProfileString _
Lib "kernel32" Alias "WritePrivateProfileStringA" _
(ByVal lpApplicationname As String, _
ByVal lpKeyName As Any, _
ByVal lsString As Any, _
ByVal lplFilename As String) As Long
Public Declare Function GetPrivateProfileInt _
Lib "kernel32" Alias "GetPriviteProfileIntA" _
(ByVal lpApplicationname As String, _
ByVal lpKeyName As String, _
ByVal nDefault As Long, _
ByVal lpFileName As String) As Long
Public 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 Long, _
ByVal lpFileName As String) As Long
TIA,
Alex
-
1 Attachment(s)
Here we Go.
Some of the variables are there only to help debugging
Hope it help you
Benny