Sat Apr 05, 2003 1:29 am by Lancer.Theta
Eh. Why read the value in as a number at all? Why not use the native WinAPI to read the value in as a string, manipulate it, and write it back as a string?
Below is a snippet from the form/module code for the editor i was working on:
Declare Function WritePrivateProfileString Lib "kernel32.dll" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Long
Declare Function GetPrivateProfileString Lib "kernel32.dll" 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
I used these API functions to fashion my own functions (for convenience):
Private Sub WriteConfig(ByVal HEADER As String, ByVal KEY As String, ByVal DATA As String, PATH As String)
Dim wcResult As Long
wcResult = WritePrivateProfileString(HEADER, KEY, DATA, App.PATH + PATH)
End Sub
Private Function GetConfig(ByVal HEADER As String, ByVal KEY As String, PATH As String) As String
Dim uname As String
Dim slength As Long
uname = Space(255)
slength = GetPrivateProfileString(HEADER, KEY, "UNKNOWN", uname, 255, App.PATH + PATH)
uname = Left(uname, slength)
GetConfig = uname
End Function
Hope this helps!