?
Solved

How to Read/Write to a text file in eVB 3.0

Posted on 2004-09-06
6
Medium Priority
?
374 Views
Last Modified: 2008-02-01
I am trying to make my appliction use a "setup.ini" file so it can load users preferences etc...

PLEASE NOTE I AM USING eVB 3.0.

1) How do I create the file (with Default options) if it does not already exist or has been deleted ?
2) How do I read certain values from the file ?
3) How do I change/write certain values to the file ?

The format of the Setup file is just like a standard INI file:

[OPTIONS]
option1=test1
option2=test2
option3=test3

Thanks in advance...

 
0
Comment
Question by:marhk51
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 18

Expert Comment

by:JR2003
ID: 11988642
0
 
LVL 18

Expert Comment

by:JR2003
ID: 11988648
The standard way to do this type of thing now is to use the GetSetting and SaveSetting functions to read and write to the registry instead of an ini file
0
 

Author Comment

by:marhk51
ID: 11989230
That won't work with eVB 3.0 !
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 13

Expert Comment

by:imarshad
ID: 11989418
EVB 3.0 has a file control........You can use this control to open a text file and read its parameters (Line by Line) and then you can also write back to the file using the same control (I have used File Control for only reading but writing will not be that much difficult).......

Imran Arshad
0
 

Author Comment

by:marhk51
ID: 11989763
Thanks for that, but I need someone to write some code so that I can pick out certain lines from the INI file.
0
 
LVL 13

Accepted Solution

by:
imarshad earned 400 total points
ID: 11990486
This is a sample code from a book emBedded VB......You can read the sample chapter that deals with files reading and editing by visiting the following link.....It contains loads of source code some of which is shown below......

http://www.samspublishing.com/articles/article.asp?p=27220&seqNum=4

Public Function GetFileTextContents(Path As String) As String
    Dim filFile As FILECTLCtl.File
    Dim strInput As String

    On Error Resume Next

    ` Get our application File object
    Set filFile = GetFileObject()

    ` Open the File
    filFile.Open Path, fsModeInput, fsAccessRead

    ` Make sure the call to Open was successful
    If Err.Number <> 0 Then
        MsgBox "Open Method failed." & vbCrLf & _
            "The file could not be read.", _
            vbCritical, "Error"
    End If

    ` Loop through file, filling our input buffer
    Do While Not filFile.EOF
        strInput = strInput & filFile.Input(1)
    Loop

    ` Close the file
    filFile.Close

    ` Release the File Object
    Set filFile = Nothing

    ` Return the text
    GetFileTextContents = strInput
End Function

After using that function you can edit every line that you want to and then save it back to the File path ........
Hope this helps.....
Imran Arshad
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question