PDA

Click to See Complete Forum and Search --> : I need the source code for saving data to a preference file!


czaries
Jan 9th, 2000, 06:35 AM
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

Dayo312
Jan 9th, 2000, 08:47 AM
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

Dayo312
Jan 9th, 2000, 08:52 AM
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 = "john@vb-world.net"

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

Dayo312
Jan 9th, 2000, 08:56 AM
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?

czaries
Jan 10th, 2000, 10:28 AM
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

Clunietp
Jan 10th, 2000, 11:10 AM
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....