Results 1 to 4 of 4
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VB - app runs from C drive but not network

    I'm a novice to VB.
    I have created an application that reads info from an ini file & displays in message box.

    I can run the app from my C drive.
    However when I place app on network & run from the network
    it doesnt pick up the ini file key.

    Do I need to specify path of ini file in my code?
    As I thought if ini file is with my app & I have specied the name will read from within that directory?

    ALso are there any other steps I should be doing?
    Much appeciated TIA
    Diana

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    New Lounger
    Join Date
    Dec 2000
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB - app runs from C drive but not network

    Hi Diana,

    How do you read the INI file?
    I use:
    x = System.PrivateProfileString(FilePath, "Section", "key")
    and I specify the full path of the file to make it work.

    The Help tells me the following, which indicates that it might be searching the Windows folder:

    expression.PrivateProfileString(Filename, Section, Key)
    ...

    Filename - Required String.
    The file name for the settings file. If there's no path specified, the Windows folder (Windows) or the Preferences folder (Macintosh) is assumed. If you're using Windows 95 or Windows NT to return a setting from the registry, Filename must be an empty string ("").


    Hope this helps,
    Margaret

  4. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB - app runs from C drive but not network

    Hi Margaret

    In VB - to read the ini file I have the following code.

    The code works when run on my c drive.
    However when testing on another users pc the path of the ini file is displayed instead of the value of the kye.
    When I change the code & insert full path of ini file - & run on other users pc - the path is displayed.

    Its like the code is not locating or reading the ini file key's value.
    In VB I thought you didnt have to hard code the location of ini file if in same location as project.

    WhenI dont hard code path for ini file & test from my pc - it works - ie it reads the ini file value & displays.


    Private Sub Form_Load()

    Dim lngResult As Long
    Dim strFileName
    Dim strResult As String * 50
    Dim strHeading As String
    Dim strKey As String

    strFileName = "UserMsgBox.ini"
    strHeading = "GenericMessage"
    strKey = "MessageText"


    'call function to obtain information from ini file
    lngResult = GetPrivateProfileString(strHeading, _
    strKey, strFileName, strResult, Len(strResult), _
    strFileName)

    'if string length is 0 -an error has occurred or no text
    If lngResult = 0 Then
    lblMessage = ("Error! Could not find text message.")

    Else
    'else display text found in ini file
    lblMessage = Trim(strResult)
    End If



    In the module I have declared the following functions:

    Option Explicit

    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 '

    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

  5. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: VB - app runs from C drive but not network

    Have you used code to write the private profile string on the machine that doesn't work and then tried running this code?
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •