Const & Environ?
Is there some great fun trick that will allow you to set the value of a Const = to an environment variable??
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Why doesnt Environ("something") work for Windows 98 , only on Xp.
I need to be able to get...
Common Program Files i.e "C:Program FilesCommon Files"
Program Files i.e "C:Program Files"
SystemDrive i.e "C:"
Userprofile i.e "C:Documents and SettingsBob"
AllUsersProfile i.e "C:Documents and SettingsAll Users"
And i Need to be able to get The desktop
Win 98 - ( I think its ) C:WindowsDesktop <= can anyone help me
Win Xp - C:Documents and settingsUserNameDesktop
Im not familiar with directories for Win 98. Can someone help me get all the above without using Environ since it doesnt work. Thank you
other than "windir", wut other parameter can u use wit the environ function?
I'm trying to understand how to work with "environ" in Visual Basic 6 and i can't figure it out.
Please if someone can write me some explanation or some part of code that contained the "environ" issue.
ok folks - here it is: i am looking for a list of all the possible variables to be used with the Environ$("String") function. does anyone know a website where these are listed? or can anyone help direct me to a place where i might find information about this function? thanks a lot for all your help.
I was just reading a most interesting faq by DaVBman on using the Environ("APPDATA") command rather than app.path and this seems an excellent suggestion.
There are a couple of things I'm not sure about though.....
Is Environ("APPDATA") always available ?
Has it always been available (ie will it work on w95 systems)?
Edited by - IanB on 2/24/2005 9:23:00 AM
Can someone give me a list all the environment variables(with description) which i can access throug environ("--").Is it possible to generate a list dynamically?I mean can i loop through all of them?
What windows versions will Environ("ProgramFiles") or Environ("SystemRoot") not work on?
VB Environ Function
I am using the VB Environ function to get the logged on userid. The app getting this information is in a web app on a web server. When I call the app it seems to be getting the userid of the web server not the userid of the calling user.
Is it possible get the userid of the user calling the function not the userid of the server?
I'm running one VB program from another VB program using the CreateProcess API function. The new process is supposed to inherit the parent environment, but no environment shows up when I use the Environ function in the child process. Any thoughts?
VB6, Environ And Vista
(This is the second time I'm asking this because I never got answers)
The Environ function will work under Vista to retrieve the username/computer name ? Does Vista have users just like Win XP ?
I put an easter egg on my last program,if the username is Elena some flowers will pop up. It works fine under XP...I was wondering if it's suppoerted also under Vista.
PS No, I don't want to use the API, I want to use Environ cos it's faster and easier.
Environ And Vista
I was wondering if Environ (VB6) will work fine under Vista to determine PC name,username etc etc...
Have you tried it under Vista ?!
I need some urgent help please. I am trying to finish a project for my company using my PC at home.
I have taken a copy of my VB6 application from work and put it on my home PC. When I try and run the application it fails when the Environ command is used.
I get a compile error: Cannot find Project or Library.
Is there a reference that I need to add to the project? I am running Windows XP Home here at home and Windows 2000 at work.
Please can someone help as soon as possible as I need this work done.
I have tried commenting out the line but the same error appears when I use the right() command?
This is probably a dumb question, but I'm some what of a newbie so I will ask.
Is there a way to set a Public or Global variable equal to the results of an Environ call? I keep getting an "Invalid call to outside Procedure" error when I try this. I want to avoid making this environ in every modual, class and form.
Get All Environ Functions On NT?
How do I get all Environ Functions on my NT computer like this:
MsgBox Environ ("USERNAME")MsgBox Environ ("USERDNSDOMAIN")MsgBox Environ ("USERDOMAIN")MsgBox Environ ("LOGONSERVER")MsgBox Environ ("COMPUTERNAME")MsgBox Environ ("APPDATA")MsgBox Environ ("USERPROFILE")MsgBox Environ ("SYSTEMDRIVE")
where can i get a list of variables for using the eviron$ function. i know of "windir" and "computername", but what are some more?
i'm hoping one will give me the drive letter of the drive that windows is installed on. that is unless someone could show me how to get the "C:" part of the string "C:Windows" (where C is the drive from using the windir environ).
nevermind, i'm stupid. i just remember i could just use Left$(windir,3)
can someone give me a list of all the environ varibles and what information a can get from them?
Thanks in advance for any reply.
I have inherited a VB project to make some changes to. I do not know what version of VB it was originally developed under. My problem is that it uses the Environ function but my VB6 development environment complains when it comes to that particular line of code. I get the error: "Compile error. Can't find project or library."
Here is the segment where it is used:
Do Until MyRS.EOF = true
If UCase(Environ("USERNAME")) = MyRS.Fields("USERNAME") then
Admin_Rights = true
mnuTools.Enabled = true
mnuFileAdd.Enabled = true
mnuFilePrint.Enabled = true
Using Environ in a brand new project works as intended I just don't know why this project doesn't like it.
Does Environ Work On All Windows?
Does environ work on all windows versions from Windows 98 on up? I'm using it to determine the username logged on the computer.
Environ Function Question
Does any know where I can find a list of what all works with the Environ("") call?
I tried looking under the environment variables in the systems property but I know there's more that that.
Environ Problem In Acces Project
i have a problem with the Environ function.
I've convert a .mdb file into an access project .adp (with the upsize facility).
All my tables had columns with the Environ function as default value, used to track the users who access and write data etc.
In the project I get the error message "Unknown function Environ$...............".
Of course I can use a code to insert values into those columns from the different forms but I just wanted to know if there is a method to use in the project tables a similar quicker solution ( I've tried various things in the past 3 hours in the design view of the project tables at the "Default value" and "Formula" but I cant get them work ).
Thanks a lot.
Why Doesn't Environ$() Find My Environment Variable?
I'm running VB6, SP6, on XP, SP2 (with fingers crossed, rabbits feet all about)
SetEnvironmentVariable "MY_ENV_VAR", "123"
I can see the environment variable set to 123,
but Environ$( "MY_ENV_VAR") returns an empty string.
The docs state this
If envstring can't be found in the environment-string table, a zero-length string ("") is returned. Otherwise, Environ returns the text assigned to the specified envstring; that is, the text following the equal sign (=) in the environment-string table for that environment variable.
I don't understand why I can see the var in the shell, but not with Environ$( "MY_ENV_VAR")
Const But Not Const
I have a Type set up to hold an array of playing cards. My Type is started as a dynamic array, and is redimmed in a function that sets up the cards. I want to let the rest of the program read the numbers in the array, but not be able to edit them in any way. Const is the only thing I can think of, but that obviously won't work. So in short, how can I set integer arrays that are part of a Type, and then allow the rest of the program to see the contents of the array, but not edit them. Thanx
How To Use CONST?
qtion, its more of educational qtion that technical. being new in VB is there any resource that will explain how to use: Private Const
As Long = &H4000
and what does the &H4000 means?
Uses Of Const
What is the Const statement used for-gives some examples,and how is it used in procedures?
hmm... after that Msgbox tricks,
Now, to continue that, I need to ask some question.
How to set the value at below declaration ?
Private Const MB_ICONINFORMATION As Long = &H40&Private Const MB_ABORTRETRYIGNORE As Long = &H2&Private Const MB_TASKMODAL As Long = &H2000&
I got it from :
I confuse with that &H40&, &H2&, &H20000&
How can we know that MB_ICONINFORMATION = &H40& ???
How can we know that MB_ABORTRETRYIGNORE = &H2& ???
Nd How about for :
someone know the value ? or at least how to find the value of that things....
*** Wille ***
VB Const PI?
Does vb have the PI constant or do I need to declare it myself and give it a value?
Const And Chr(0)
I know this doesn't work:
Public Const Message_Start = Chr(0)
But what can I use instead?
what does this "Const" thing do?
Const m_def_AcceptType = 0
I've found something like that:
[c] #const MY_CONST = False [/c]
Does anybody know what the '#' at the beginning means?
Is it possible to define an array as a constant? if so how?
CONST AND DIM?
WHAT IS THE DIFFERNECE BETWEEN A CONST AND DIM cant u just type
x = 100
instead of the devlopers who wrote vb putting the const 'thing'
Const = 100
HOW DO I DELETE THE TOPIC??? I CAN T BY CLICK ADMIN THEN DELETE. I DONT HAVE ADMIN POWER
Edited by - thomas49th on 1/13/2005 2:41:45 PM
Use CONST In Vb6
i want to use CONST in my vb6 application.
but i have a question:
is the CONST pre compiled or whenever vb see CONST it goes to check the CONST value?
How To Convert Const
how do i convert
#define myvariable 0X91
to vb code i have
public const myvariable as string = "0x91"
but i do not know if that is write
Use Textbox In Const
I have a code where i use a const and i want to use a textbox to display the text.
If i do this
Const Display = "The displayed text here"
Const Display = Text1.Text
then everything works fine but if i replace "The displayed text here" with Text1.Text. then it gives an error. It says Constant expression required. Is there a way to use a textbox??
Using Const ... Well Sort Of
I have an program that takes in 2 exchange rates off the user.When these exchange rates are taken in i would them to be global and const.
i use the exchange rates through out the program and i do not want them to change.is there anyway to do this
I know about declaring Variable as const from the start of the program. like
Private Const DaysInWeek = 7
But how would i implement this during the program?
Static Vs. Const
What's the difference between a static variable and a constant? What's the point of having either?
Also, I find this kind of funny, because "static variable" is an oxymoron.
whats the difference between
Private Const TARGETFOLDER As String = "My Documents"
Dim TARGETFOLDER AS String
Targetfolder = "My Documents"
is it to save a line of code
or does const have other advantages
I have a bunch of public constants in a module. Is there any way that you can have them in a text file and then somehow load them into my app?
Does anyone know how make VB do the list pop up thing like when you use a msgbox. It has [buttons as VBMsgBoxStyle = VbOkOnly] as the attribute.
Const Array ?
How do I declare an array of constant strings ?
Const contarray() as String = ("const1", "const2", "const3")
Thanks in advance
Const sFile As String = App.Path & "Schedule.ini"
Getting a 'Constant expression required' compile error. Path is highlighted and I can't figure out why it wont accept the file path string.
Const COLOR_HIGHLIGHTTEXT = 14.... Again
"Const COLOR_HIGHLIGHTTEXT = 14" changes the highlighted text and "Const COLOR_HIGHLIGHT = 13" changes the background of the highlighted item... How do you change the colour of non-ehighlighted items?
Values For Const
am quite new with APIs, am not getting how i can assign values to the CONSTANTS.
Private Const SPI_SETDESKWALLPAPER = 20
Private Const SPIF_SENDWININICHANGE = &H2
Private Const SPIF_UPDATEINIFILE = &H1
where these value comes from
am really surprised with the API. any help can be appreciated
Hi guys, i have code that opens a txt file and i have code to save text to txt files but i need the path that the user picked using the "Open Dialog"
Dim filename As String 'So we can find the filename Dim F As Integer CommonDialog2.Filter = "Text File (*.txt)|*.txt |NFO File (*.nfo)|*.nfo |Log File(*.log)|*.log|All Files (*.*)|*.*" 'Filters only for txt files CommonDialog2.ShowOpen 'Open it filename = CommonDialog2.filename ' So filename = something If Len(filename) = 0 Then 'error trap Print vbNullString Else F = FreeFile Open filename For Input As #F 'Opens filename for loading Text1.Text = Input$(LOF(F), F) ' Text2 = the input of Length of file(freefile), freefile Close #F 'Closes the loading, so it isnt running End If
Dim strBuff As Stringff = FreeFileOpen HERES THE PROBLEM For Output Lock Read As #ff 'open yay.txt Print #ff, Text1.Text '"print" text1.text into yay.txt Close #ff 'close yay.txt
So i dont know what to use as the file path..from the loading part or do i need to use a Const ...Thx
Const With Slider
Im using this:
Const Delaytime = 1000 / 15
To determine the speed of the animation for test reasons I want to make a slider changing the second value(where 15 is), I guess I shouldn't make it a constant value , since they never change. Thx for your time.
Enum Vs. Const
What's the difference between Enum and Const other than the little drop-down box in the IDE when using an Enum in a Sub/Function declration? I'm going to have a bunch of arrays that are numbers that mean different things and want to use something other than numbers to check values so that I don't have to remember what every number for every type means. They will be global either way. But, I'm not sure if I should use constants or enumerations or what the benfits would be for each.
How To Declare A Const = Chr(2)?
I'm trying to declare a string constant consisting of a simple chr(2) character. Since the expression "chr(2)" is no constant but a string function, VB refuses to accept the definition.
Const STX = Chr(2) 'Doesn't work
How do I fix this? Any help is highly appreciated. Thanx