 |
| Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET). |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

April 18th, 2008, 04:12 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
|
|
Enviromental Variables
Howdy,
What other environmental variables apart from "USERNAME" are there? Also how do you know about them?
This is mainly targetted at Brian Wren but feel free to answer.
Cheers
------------------------------------------------
Apocolypse2005
Always ready and waiting to be helped! Soon changing as I have got so much better as a programmer!
__________________
Apocolypse2005, I'm a programmer - of sorts.
|
|

April 18th, 2008, 04:21 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
If i have understood you correctly, you are looking for the environement variables of both the system and the user? To view these right click on 'My Computer' go to properties, select the Advanced tab, then at the bottom of that tab press the Environment Variables button. (This is both user and system variables).
If memory serves me, you can access any of this by doing something like Environ("[variable]"), I could be wrong but I think thats what it is.
hth.
-Doug
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
|
|

April 18th, 2008, 05:07 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
It would be easier to answer if you could give an idea of what brings this question to mind, or what it is that you want to do.
|
|

April 20th, 2008, 02:38 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
|
|
Well Mr Wren, this is needed for when your rooting through someones file structure.
So when i need to know whether some one has a my music or what drive they have there my documents on.
|
|

April 21st, 2008, 12:47 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
I don't think your understanding is right (or mine isn't...).
When I look on my machine, MyDocuments (no space in the name) is under DocumentsAndSettings\<my logon>
So once you have thier logon, the rest is the same for everyone.
If you can specify an alternate location for these files (MyMusic is under MyDocuments), I'm unaware of that.
I'm not sure how to get the full list of environment variables. Iâm sure you can, because typing C:\>SET at a DOS prompt will list them all. That means that the OS is willing to comply, if you can find the API to ask correctly...
|
|

April 22nd, 2008, 11:58 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
But to answer the specifics you asked...
Use Environ().
There are 2 ways to use Environ(). If you pass the [u]name</u> of an environment variable Environ() returns the value of that variable, or a blank string if the variable is not defined.
If you pass a [u]number</u>, Environ() returns the entire environment string (the variable name, the equal sign and the value) of the variable at the specified position.
If there is no variable at the specâd pos., Environ() returns a blank string.
Code:
Private Sub SomeSub()
Dim EnvSet As String ' "Set" because it returns the name/val set.
Dim idx As Integer
idx = 1
Do
EnvSet = Environ(idx)
Debug.Print EnvSet
idx = idx + 1
Loop Until EnvSet = ""
End Sub
|
|

April 23rd, 2008, 04:23 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
|
|
So this could find out all the environment variables?
That c:\> set works a treat, you can get shed loads of information about the computer, thats what I was looking for,
Cheers Brian (thats why they call you a senior member ;) )
|
|

April 25th, 2008, 04:32 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
Actually, they call me a Senior Member because I haunt this place, and can't keep my mouth shut...
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| variables |
daniel.mihalcea |
Javascript |
1 |
September 9th, 2008 07:06 PM |
| using variables |
webgrphx |
Classic ASP Basics |
3 |
April 11th, 2007 06:46 PM |
| Passing Variables |
silve1999 |
Pro Java |
1 |
June 15th, 2006 12:54 PM |
| Passing variables |
acko |
ASP.NET 1.x and 2.0 Application Design |
1 |
December 23rd, 2003 09:40 AM |
|
 |