Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    [VB6] - Program Files Variable?

    Is there a variable I can use in a string for Program Files?

  • #2
    Super Moderator sage45's Avatar
    Join Date
    May 2002
    Posts
    1,060
    Thanks
    0
    Thanked 13 Times in 13 Posts
    The %programfiles% variable at the DOS level will give you the program files directory. If your dealing with an x64 Windows Operating system you also want to look for an x86 Program Files directory.

    Code:
      Dim i as Integer
      Text1.Text = ""
      i = 1
      While Environ$(i) <> ""
        Text1.Text = Text1.Text + Mid(Environ$(i), 1, InStr(1, Environ(i), "=") - 1) + vbNewLine
        i = i + 1
      Wend
    Provides the environment variables on a particular system.

    To actually assign an environment variable to a variable in your application you would use:
    Code:
    dim strProgramFile as string
    strProgramFile = Environ(”ProgramFiles”)
    Here is a link that tells another technique to use: http://vbtechniques.com/content.asp?a=co&cID=624

    -saige-
    HTML & CSS Forum Moderator

    "If you don't know what you think you know, then what do you know."
    R.I.P. Derrick Thomas #58
    1/1/1967 - 2/8/2000


  •  

    Posting Permissions

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