Search: Key Word(s): vb
Showing results 1 to 25 of 134
I think that explains why this thread is justified.
Search: Key Word(s): vb
Showing results 1 to 25 of 134
I think that explains why this thread is justified.
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
There is many Programming forum like the nice www.experts-exchange.com/ but they're not really hardware oriented... well those i know so far.
http://www.programmersheaven.com/ is another great source.
Or 1 Million in my bank account will be 'tha solution' LMAO!
Last edited by mister_e; - 25th August 2006 at 04:36.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
What techniue would you use to store a "cookie" in VB? I set a drive, folder and filename in a form and I'd like to save that value between sessions.
Is there a nice and efficient way of doing this besides writing to a text file? Is there a standard way of doing this? I'd prefer a technique where the user could not get his grubby hands into the file and screw up pointers.
Robert
![]()
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
I use INI files... that's mainly what they're for. Here's a module I use for them. Just add it to your project and use WriteProfileString & FetchProfileString functions to write and read to the INI file.Originally Posted by Demon
Here's an example of reading in the language value under the Section named SAP in the Pack.ini file.Code:'ModINIFunctions.bas Option Explicit Private msWinPath As String Private mlRetLength As Long Private msDirReturn As String 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 Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long Public Function FetchProfileString(ByVal sINIFile As String, ByVal sApp As String, _ ByVal sKey As String, Optional DefVal As Variant) As String 'Purpose: Reads information from a *.INI file 'Inputs: sINIFile String Name of file INI file including path ' sApp String Name of application section in INI file ' Example [My App] ' sKey String key name under application section ' DefValue String default value of key ' ' Example [MyApp] ' MyKey = MyValue 'Assumptions: ' 1. Windows API GetPrivateProfileString function declared with the following statement in the ' 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 ' 'Effect: None Dim sReturn As String Dim sDefVal As String Dim mlReturnLength As Integer If IsMissing(DefVal) Then sDefVal = "" Else sDefVal = CStr(DefVal) End If ' msDirReturn = Dir(sINIFile) ' If msDirReturn = "" Then ' mlRetLength = WritePrivateProfileString(sApp, sKey, sDefVal, sINIFile) ' End If sReturn = String$(255, 0) mlRetLength = GetPrivateProfileString(sApp, sKey, sDefVal, sReturn, 255, sINIFile) FetchProfileString = Left$(sReturn, mlRetLength) End Function Public Function WriteProfileString(ByVal sINIFile As String, ByVal sApp As String, _ ByVal sKey As String, ByVal sVal As String) As Boolean 'Purpose: stores information to a *.INI file 'Inputs: sINIFile String Name of file INI file including path ' sApp String Name of application section in INI fil ' Example [My App] ' sKey String key name under application section ' sValue String value of key ' ' Example [MyApp] ' MyKey = MyValue 'Assumptions: ' 1. Windows API WritePrivateProfileString function declared with the following statement in the ' Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" ' (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long ' 2. if *.INI file does not exist this function will create the file 'Effect: Contents of *.INI file Dim sReturn As String mlRetLength = WritePrivateProfileString(sApp, sKey, sVal, sINIFile) End Function
Here's an example of how the data in the INI file would look.Code:PstrLang = FetchProfileString(App.Path & "/PACK.INI", "SAP", "LANGUAGE", "EN")
This is a really useful way of storing different user preferences etc.Code:;comments use the semicolon ;In this example parameter sApp = SAP ;parameter sKey = Language (there can be multiple keys under one app parameter) ;The value returned to PstrLang in the example above is EN [SAP] LANGUAGE=EN
Another method would be writing and reading to the registry. But I'll let you explore that option.
Last edited by Demon; - 4th October 2016 at 17:55.
Wisdom is knowing what path to take next... Integrity is taking it.
Ryan Miller
Thanks, that looks great.
I'm not too keen on writing to the registry.
Robert
EDIT: Are you sure about this statement?
-----------------------------------------------------
Here's an example of reading in the language value under the Section named SAP in the Pack.ini file.
Code:
PstrLang = FetchProfileString(App.Path & "/PACK.INI", "SAP", "LANGUAGE", "EN")
-----------------------------------------------------
Why read the INI file to find sValue if you are providing it in the statement? This would look more like a Write statement no?
Last edited by Demon; - 25th August 2006 at 16:59.
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
This one is really off-topic.
I'd like to copy an Access MDB file from within VB6. I don't even know where to start looking for this. I figure this could be some sort of batch file like we used to be able to do in DOS.
Robert
EDIT: Hmmm: http://builder.com.com/5100-6373-1050078.html CopyFile feature, interesting.
Last edited by Demon; - 27th August 2006 at 17:26.
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
I found this:
FileSystemObject.CopyFile "c:\mydocuments\letters\*.doc", "c:\tempfolder\"
But I'm stuck on how to define that FileSystemObject.
Robert
EDIT: Found it, I needed to add a Reference to Microsoft Scripting Runtime (scrrun.dll).
Last edited by Demon; - 27th August 2006 at 18:19.
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Look at the FetchProfileString function. You have to provide a default value in this call, then it gets overwritten with what's in the INI file.Originally Posted by Demon
Last edited by Demon; - 4th October 2016 at 17:55.
Wisdom is knowing what path to take next... Integrity is taking it.
Ryan Miller
How do we point to a VB6 public variable from within a SELECT statement?
Set rsProfile = dbProfile.OpenRecordset("SELECT * FROM tblProfile WHERE ptrMenu = ptrCurrentMenu")
Both ptrMenu (primary key) and ptrCurrentMenu are defined as LONG, but it only works when I hardcode a 1 instead of ptrCurrentMenu.
Robert
EDIT: Found it in Programmer's Heaven, thanks Steve: ("SELECT * FROM tblProfile WHERE ptrMenu = " & ptrCurrentMenu)
Last edited by Demon; - 29th August 2006 at 23:51.
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
The thing is that several of us are going to go through the same steps. It would be a waste of resources to let people have to sprawl all over when all we need are a few good tutorial links and some help on a few questions.Originally Posted by mister_e
I'm sure there are tons of good places for GSM, GPS and Bluetooth information. What's the difference? This is just another application that will use PIC and PBP. And when you think about it, Windows is EVERYWHERE today, a lot more than the 3 other applications.
Robert
![]()
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Bookmarks