Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-07-2007, 04:37 PM   PM User | #1
jacksont123
New Coder

 
Join Date: Jun 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
jacksont123 is an unknown quantity at this point
[VB6] - Program Files Variable?

Is there a variable I can use in a string for Program Files?
jacksont123 is offline   Reply With Quote
Old 10-07-2007, 11:25 PM   PM User | #2
sage45
Super Moderator


 
Join Date: May 2002
Posts: 1,036
Thanks: 0
Thanked 11 Times in 11 Posts
sage45 is an unknown quantity at this point
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
sage45 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:21 PM.


Advertisement
Log in to turn off these ads.