|
-
Sep 30th, 2000, 11:30 AM
#1
Thread Starter
New Member
how can i read from a textfile?
i want to make an ini file but i am unable to manage access to certain line. so how can i specify which line the program should read and use a value?
please help me! thank you very much!
der nico kann nich lesen und schreiben
-
Sep 30th, 2000, 11:48 AM
#2
Hyperactive Member
Maybe this will help:
To write a value in an ini file:
Code:
'Declaration:
Private Declare Function WritePrivateProfileString _
Lib "kernel32" Alias "WritePrivateProfileStringA"_
(ByVal HeadingName As String, ByVal KeyName As Any,_
ByVal Value As Any, ByVal lpFileName As String) As Long
'Code to use it:
Dim Return As Long
Return = WritePrivateProfileString("Heading1", "Key1",_
"Value1", "C:\Myini.ini")
'If Return is nonzero it worked, otherwise, it failed
To read a value from an ini file:
Code:
'Declaration:
Private Declare Function GetPrivateProfileString _
Lib "kernel32" Alias "GetPrivateProfileStringA"_
(ByVal lpApplicationName As String, ByVal lpKeyName As Any,_
ByVal lpDefault As String, ByVal lpReturnedString As_
String, ByVal nSize As Long, ByVal lpFileName As String)_
As Long
'Code to use it:
Dim Return As Long
Dim Value As String
Value = String$(255, 0) 'The 255 is the length, the 0 is the char(Return).
Return = GetPrivateProfileString("Heading1", "Key1",_
"C:\Myini.ini", Value, Len(Value), "C:\Myini.ini")
'If Return is nonzero it worked, otherwise, it failed
'The value of the key is specified in the 'Value' string
WP
-
Sep 30th, 2000, 12:03 PM
#3
New Member
Well, you can't use Return as a varible because it's already a RESTRICTION.
Brief, for all our sakes, turn off that darn VB!
Escaflowne's Omega Helper  .
-
Sep 30th, 2000, 05:32 PM
#4
Hyperactive Member
Yes Escaflowne is right. Return is a reserved word.
Most of us use:
Code:
Ret = WritePrivateProfileString("Heading1", "Key1", "Value1", "C:\Myini.ini")
-
Sep 30th, 2000, 05:48 PM
#5
Monday Morning Lunatic
...and still others use lRet or sRet or whatever data type it is...
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 30th, 2000, 05:53 PM
#6
Hyperactive Member
Originally posted by parksie
...and still others use lRet or sRet or whatever data type it is...
Good point Parksie, makes code easier to understand by just looking at it.
-
Sep 30th, 2000, 07:27 PM
#7
I find that a lot of people use Retval which means Return Value.
-
Sep 30th, 2000, 09:29 PM
#8
_______
<?>
..and some of us just prefex the reservered word
eg... sName or lReturn
...it's a case of preference when it comes to naming variables and one should use varnames that relate to what
you are trying to express in them so others behind you won't struggle with the code... ie. ireflex for Return
surely wouldn't make your variable very easy in association.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|