Microsoft
Software
Hardware
Network
Question : declaring constant variables using if's and elsif's
I have a workgroup that stores userid's and pwd's, these are in the format of the user's windows nt logon id.
in a startup function, I'd like to parse the ID's into the person's name.
IE:
Public Function Startup()
If CurrentUser = "sgrafl01"
const username as String = "Sean Graflund"
Elseif CurrentUser = "dmarti01"
const username as String = "Donald Martin"
ElseIf .... and so on
End if
End Function
I have about 12 logon ID's I'd do this with. It works fine with standard global strings, but I'd like to turn it into a constant. For some reason, after using the DB for awhile the global string turns to a zero lengh string. If I use a const string, it will always have it.
When I try to declare this as a constant, VBA gives a declaration declared multiple times error. Is there a way I can assign this as a const without getting that error or will I have to change all the User ID's to the correct person's name in the workgroup manager instead of using the same ID as is used for the Windows NT logon?
Answer : declaring constant variables using if's and elsif's
Declare a public variable:
Public g_username As String
Then set the value in your function:
Public Function Startup()
If CurrentUser = "sgrafl01"
g_username = "Sean Graflund"
Elseif CurrentUser = "dmarti01"
g_username = "Donald Martin"
ElseIf .... and so on
End if
End Function
P.S. You may find it easier and more maintainable to put these values in a table.
Random Solutions
I got a FPT file corrupted
problem of do while loop iin foxpro
Using TSADMIN.msc is there a way to tell which user is at a desktop, which is using remote app?
Shutdown VM in ESXi 4.0 when connected to a smart ups 1000
How Can I Detect, Delete, and Add A Printer In Windows XP using Visual Basic, C#, or C++
Access2003: working with mouse wheel
ASP.Net page slow to load large dropdown list
Where does XPS driver print or save the file to and what extention
How Do I Make the Choices in One Access Form ComboBox Contingent upon a Choice in Another?
Why does Excel 2003 crash intermittently when this line is run?