Results 1 to 6 of 6

Thread: I need the source code for saving data to a preference file!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Posts
    16

    Post

    I need the source code for the followign things:
    • Saving data to a preference file, and accessing it later. (Like a save your current settings option- like a .cfg file)
    • I also need to know how to load the smae file for use later.
    • I have just 1 more thing if it isn't too much of a bear - the Source code for visiting a website through the click of a button.

    Thank you for your time

    ------------------
    Webmaster Czaries
    http://www1.50megs.com/css

  2. #2
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184

    Post

    No Problem.

    Jus play with this, If I see another post from you ill assume there was a prob.. So Ill try to help you.

    'In a Module
    Public Declare Function GetPrivateProfileSectionNames Lib "kernel32" Alias "GetPrivateProfileSectionNamesA" (ByVal lpSectionNames As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
    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

    'Theres two Extra calls you Might need
    'To record
    Dim retval As Integer
    retval = WritePrivateProfileString("Prefs", "Pref", YOURVALUE, App.Path & "\startup.cfg")
    looping = looping + 1

    'TO LOAD THE VALUES
    Dim countcurrent As Integer
    Dim lRet As Long
    Dim i As Integer
    Dim arrPieces()
    Dim iIndex As Integer
    Dim strBuffer As String
    Dim looping As Integer
    For i = 0 To 11
    strBuffer = Space(1024)
    lRet = GetPrivateProfileString("Prefs", "Pref", "", strBuffer, Len(strBuffer), App.Path & "\startup.cfg")
    If lRet Then
    YOURVALUE(iIndex) = Left(strBuffer, lRet)
    End If
    iIndex = iIndex + 1

  3. #3
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184

    Post

    I didnt write it in HTML so you cant Copy in paist, Just Highlight it and Drag it to the VB window and release it, That should work fine...

    Heres the other code you wanted..

    Option Explicit
    ' VB-World.net global support library for demo projects
    ' John Percival, Feb '99


    Public Const URL = "http://www.vb-world.net"
    Public Const email = "[email protected]"

    Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    Public Const SW_SHOWNORMAL = 1

    Public Sub gotoweb()
    Dim Success As Long

    Success = ShellExecute(0&, vbNullString, URL, vbNullString, "C:\", SW_SHOWNORMAL)

    End Sub

    Public Sub sendemail()
    Dim Success As Long

    Success = ShellExecute(0&, vbNullString, "mailto:" & email, vbNullString, "C:\", SW_SHOWNORMAL)

    End Sub


  4. #4
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184

    Post

    Hey,

    I Was looking at your webpage (Im bored). And I noticed you a Altavista link. If you use freeaccess I make a program to minimize it when it pops up (its annoying) .

    Do you want it?


  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Posts
    16

    Post

    Thank you for your replies. I will be sure to try them out and see how they work. I do not use AltaVista's internet access, I use a local ISP. The banners on my webpage are through an ad agency that I get money ($0.10) per click.

    ------------------
    Webmaster Czaries
    http://www1.50megs.com/css

  6. #6
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    I would suggest use GetSetting/Savesetting to store your settings instead of your own preference file....

    1 line of code to save a preference, 1 line of code to retrieve it....

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