|
From: Tommy Long on 2 Jul 2008 11:35 I know how to do it in VB6, I have code snippets coming out my ears for VB6, but with the new framework in Visual Studio 2005, how do you get/put from a ..INI If I attempt to use a VB6 snippet in Studio 05 it whinges about using the 'as Any' type in my declarations, and it whinges about using the String$() function when creating a buffer string variable. Infact, it whinges a whole lot, why my employer got VS05 I'll never know. :( Anyway, thanks in advance for any help. If people have simple alternatives for the use of .ini's for my future reference, that'd be handy as well. Assumably .xl? Cheers, Tommy -- ------------------------------- Please respond to my posts via the newsgroup as the e-mail provided is not monitored.
From: Tommy Long on 2 Jul 2008 11:43 Found it, Never mind. Linked below: http://www.developer.com/net/asp/article.php/3287991 -- ------------------------------- Please respond to my posts via the newsgroup as the e-mail provided is not monitored. "Tommy Long" wrote: > I know how to do it in VB6, I have code snippets coming out my ears for VB6, > but with the new framework in Visual Studio 2005, how do you get/put from a > .INI > > If I attempt to use a VB6 snippet in Studio 05 it whinges about using the > 'as Any' type in my declarations, and it whinges about using the String$() > function when creating a buffer string variable. Infact, it whinges a whole > lot, why my employer got VS05 I'll never know. :( > > Anyway, thanks in advance for any help. > > If people have simple alternatives for the use of .ini's for my future > reference, that'd be handy as well. Assumably .xl? > > Cheers, > Tommy > > -- > ------------------------------- > Please respond to my posts via the newsgroup as the e-mail provided is not > monitored.
From: Tom Shelton on 2 Jul 2008 11:45 On 2008-07-02, Tommy Long <TommyLong(a)discussions.microsoft.com> wrote: > I know how to do it in VB6, I have code snippets coming out my ears for VB6, > but with the new framework in Visual Studio 2005, how do you get/put from a > .INI > > If I attempt to use a VB6 snippet in Studio 05 it whinges about using the > 'as Any' type in my declarations, and it whinges about using the String$() > function when creating a buffer string variable. Infact, it whinges a whole > lot, why my employer got VS05 I'll never know. :( > > Anyway, thanks in advance for any help. > > If people have simple alternatives for the use of .ini's for my future > reference, that'd be handy as well. Assumably .xl? > > Cheers, > Tommy > Hard to answer without seeing the method your using, but the basic answer is "the same way". Are you using API calls? VB6 File IO? Why don't you post a small sample of the problematic code (including api declarations if that's the method your using) - your more likely to get a correct answer that way :) -- Tom Shelton
From: Tommy Long on 2 Jul 2008 12:03 I've been using the VB6 Code, I've found an answer but in the interest of better answers, here are the declarations: 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 WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long They both throw multiple errors for their use of the 'Any' variable type. Additionally, in the following 'GetFromINI' procedure: Function GetFromINI(sSection As String, sKey As String, sDefault As String, sIniFile As String) Dim sBuffer As String, lRet As Long ' Fill String with 255 spaces sBuffer = String$(255, 0) ' Call DLL lRet = GetPrivateProfileString(sSection, sKey, "", sBuffer, Len(sBuffer), sIniFile) If lRet = 0 Then ' DLL failed, save default If sDefault <> "" Then AddToINI sSection, sKey, sDefault, sIniFile GetFromINI = sDefault Else ' DLL successful ' return string GetFromINI = Left(sBuffer, InStr(sBuffer, Chr(0)) - 1) End If End Function I receive an error for using the function 'String$(#, #)' which I don't know a replacement for in VB.NET. I'm not all that interested in converting to XL* files, though I may in the future. I believe the link I provided in my initial post contains a link near the bottom for implementing XL* procedures instead of INI though. Any help that is better for one reason or another than the class based solution I posted is much appreciated. Tommy -- ------------------------------- Please respond to my posts via the newsgroup as the e-mail provided is not monitored. "Tom Shelton" wrote: > On 2008-07-02, Tommy Long <TommyLong(a)discussions.microsoft.com> wrote: > > I know how to do it in VB6, I have code snippets coming out my ears for VB6, > > but with the new framework in Visual Studio 2005, how do you get/put from a > > .INI > > > > If I attempt to use a VB6 snippet in Studio 05 it whinges about using the > > 'as Any' type in my declarations, and it whinges about using the String$() > > function when creating a buffer string variable. Infact, it whinges a whole > > lot, why my employer got VS05 I'll never know. :( > > > > Anyway, thanks in advance for any help. > > > > If people have simple alternatives for the use of .ini's for my future > > reference, that'd be handy as well. Assumably .xl? > > > > Cheers, > > Tommy > > > > Hard to answer without seeing the method your using, but the basic answer is > "the same way". Are you using API calls? VB6 File IO? > > Why don't you post a small sample of the problematic code (including api > declarations if that's the method your using) - your more likely to get a > correct answer that way :) > -- > Tom Shelton >
From: Tom Shelton on 2 Jul 2008 12:51 On 2008-07-02, Tommy Long <TommyLong(a)discussions.microsoft.com> wrote: > Found it, > > Never mind. Linked below: > > http://www.developer.com/net/asp/article.php/3287991 I wonder why the author decided to use the Ansi functions? You can simply declare the functions as Auto and let the runtime decide the best method for the system (which on NT based boxes is going to be the W functions). -- Tom Shelton
|
Next
|
Last
Pages: 1 2 3 4 5 6 Prev: grabbing a frame from a WDM device Next: Compare Two Datatables |