o
k
q
u
e
s
t
i
o
n
s
.
c
o
m

INI Help -

I am trying to read multiple items from an INI file located in the same directory as my application. I can read different areas of the INI file but I cannot display them or use them in the same msgbox. Please see code below:

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

Dim GetRunDay As Long, GetRunTime As Long, GetLocalPath As Long, GetRemotePath As Long, GetOrigFileName As Long, GetNewFileName As Long

Dim RunDay As String * 100, RunTime As String * 100, LocalPath As String * 100, RemotePath As String * 100, OrigFileName As String * 100, NewFileName As String * 100

Private Sub Main()
Call Schedule
End Sub

Public Function iniGrab()
Dim iniFilePath

iniFilePath = App.Path & "\" & App.EXEName & ".ini"

GetRunDay = GetPrivateProfileString("RunDay", "Day", iniFilePath, RunDay, Len(RunDay), iniFilePath)
GetRunTime = GetPrivateProfileString("RunTime", "Time", iniFilePath, RunTime, Len(RunTime), iniFilePath)
GetLocalPath = GetPrivateProfileString("LocalPath", "LPath", iniFilePath, LocalPath, Len(LocalPath), iniFilePath)
GetRemotePath = GetPrivateProfileString("RemotePath", "RPath", iniFilePath, RemotePath, Len(RemotePath), iniFilePath)
GetOrigFileName = GetPrivateProfileString("OrigFileName", "OName", iniFilePath, OrigFileName, Len(OrigFileName), iniFilePath)
GetNewFileName = GetPrivateProfileString("NewFileName", "NName", iniFilePath, NewFileName, Len(NewFileName), iniFilePath)

End Function

Private Sub Schedule()
Dim fso As New FileSystemObject

Call iniGrab

MsgBox RemotePath & OrigFileName <--*** Problem ***

Set fso = CreateObject("scripting.filesystemObject")
'fso.CopyFile RemotePath & OrigFileName, LocalPath & NewFileName

'MsgBox "File copy complete!"

End Sub

I can use both varibales, RemotePath and OrigFileName in two seperate message boxes but not in the same. Not sure why or what I am doing wrong. Once I am able to use these variables together I can use them when doing my file copy and rename. Hopefully someone can shed some light.

Here is my INI file:

[RunDay]
Day=Friday

[RunTime]
Time=12:00

[LocalPath]
LPath=D:\McAfee\

[RemotePath]
RPath=\\servername\mcafee\DAT\

[OrigFileName]
OName=sdat4086.exe

[NewFileName]
NName=Setup.exe