Results 1 to 8 of 8

Thread: please help me!!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Location
    germany
    Posts
    10

    Exclamation

    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

  2. #2
    Hyperactive Member WP's Avatar
    Join Date
    Aug 2000
    Location
    Belgium
    Posts
    278

    Cool

    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

    Visual Basic 6.0 EE SP5 / .Net
    Windows XP

  3. #3
    New Member
    Join Date
    Sep 2000
    Posts
    4

    Exclamation

    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.

  4. #4
    Hyperactive Member dsy5's Avatar
    Join Date
    Jul 2000
    Location
    Lockport, NY
    Posts
    362
    Yes Escaflowne is right. Return is a reserved word.
    Most of us use:
    Code:
    Ret = WritePrivateProfileString("Heading1", "Key1", "Value1", "C:\Myini.ini")
    Donald Sy - VB (ab)user

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    ...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

  6. #6
    Hyperactive Member dsy5's Avatar
    Join Date
    Jul 2000
    Location
    Lockport, NY
    Posts
    362
    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.
    Donald Sy - VB (ab)user

  7. #7
    Guest
    I find that a lot of people use Retval which means Return Value.

  8. #8
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    ..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
  •  



Click Here to Expand Forum to Full Width