OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > Code Critique

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 30-11-2004, 17:19
Anonymous
Guest
 
Posts: n/a
Default Storing User Preferences

I am currently working on a number of scripts that I would like to store User Preferences. My current technique is to have the script create a text file and save it in the GMS directory using the File System Object. Like this:

Code:
Dim fs, objTextStream

Set fs = CreateObject("Scripting.FileSystemObject")
Set objTextStream = fs.CreateTextFile(GMSManager.GMSPath & "OBCNconfig.ini", True) 'Creates the Preference Text File

objTextStream.WriteLine txtPath ' Adds Users Preference for Path to be searched
objTextStream.WriteLine chkSearchSubDir 'Adds Users Preference for Searching SubFolders
objTextStream.Close
I was just wondering if this is the best way to handle this, or if anyone had any other thoughts? Thanks for the tips.
Reply With Quote
  #2  
Old 23-02-2005, 07:29
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

Could someone please help with this? I really need an answer about how to accomplish this.

I'm sorry I didn't log in on my original post. I wrote it at home.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #3  
Old 14-06-2005, 09:13
RobC
Guest
 
Posts: n/a
Default

You do not want to read/write/edit ini files using raw read/writes availiable in the filesystem object, it is far too hard to do so effectively, as the FSO is pretty primitive.

There are any number of open-source INI classes around written in VB. It is trivial to add them to your project.
Reply With Quote
  #4  
Old 14-06-2005, 13:21
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

The easiest way would be to use VBA's registry access functions - SaveSetting, GetSetting:

To save your value, use SaveSetting:

Code:
Dim NumCopies As Integer
NumCopies = 2
...
SaveSetting "MyCoolMacro", "Preferences", "NumberOfCopies", NumCopies
To read it back later:

Code:
Dim NumCopies As Integer
NumCopies = Val(GetSetting("MyCoolMacro", "Preferences", "NumberOfCopies", "3"))
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need User License Details Skeezix CurveWorks 3 28-07-2005 16:22
Where does COrelPhotopaint 12 keeps its Globalmacros file? cyrilgupta Corel Photo-Paint VBA 1 08-11-2004 15:02
CD11: Adding input from user form to document ddonnahoe Code Critique 2 09-04-2004 12:43
New user - curve default? - dxf conversion? Anonymous CurveWorks 2 16-05-2003 10:23


All times are GMT -5. The time now is 02:17.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com