ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Variable Case issue (https://www.excelbanter.com/excel-programming/403125-variable-case-issue.html)

J Streger

Variable Case issue
 
I have a sheet where I originally created a global const as:

Global Const RAMPUP = "RU"

Well I decided that rather than that I wanted to do an enumeration. So I
deleted the global const and created:

Public enum TestTypes
RampUp
end enum

Except that after typing VBA gave me this:

Public enum TestTypes
RAMPUP
end enum

In fact, everytime I type rampup in the code it becomes capitalized. I did a
search and it exists nowhere in my code. Excel doesn't show it in the object
browser, and I restarted Excel, but it seems to have a die hard memory that
rampup = RAMPUP. It's done this with 3 other variables I made Global
constants and then deleted. Is there a way to stop this from happening?


--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003


Chip Pearson

Variable Case issue
 
It is a known flaw in the VBA Editor (VB6 also) that when you type the name
of an enum member, the enum declaration is changed to match what you typed
rather than the opposite (correct) behavior.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"J Streger" wrote in message
...
I have a sheet where I originally created a global const as:

Global Const RAMPUP = "RU"

Well I decided that rather than that I wanted to do an enumeration. So I
deleted the global const and created:

Public enum TestTypes
RampUp
end enum

Except that after typing VBA gave me this:

Public enum TestTypes
RAMPUP
end enum

In fact, everytime I type rampup in the code it becomes capitalized. I did
a
search and it exists nowhere in my code. Excel doesn't show it in the
object
browser, and I restarted Excel, but it seems to have a die hard memory
that
rampup = RAMPUP. It's done this with 3 other variables I made Global
constants and then deleted. Is there a way to stop this from happening?


--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003



Bob Phillips

Variable Case issue
 
.... and what a pain it is !!!!!

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Chip Pearson" wrote in message
...
It is a known flaw in the VBA Editor (VB6 also) that when you type the

name
of an enum member, the enum declaration is changed to match what you typed
rather than the opposite (correct) behavior.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"J Streger" wrote in message
...
I have a sheet where I originally created a global const as:

Global Const RAMPUP = "RU"

Well I decided that rather than that I wanted to do an enumeration. So I
deleted the global const and created:

Public enum TestTypes
RampUp
end enum

Except that after typing VBA gave me this:

Public enum TestTypes
RAMPUP
end enum

In fact, everytime I type rampup in the code it becomes capitalized. I

did
a
search and it exists nowhere in my code. Excel doesn't show it in the
object
browser, and I restarted Excel, but it seems to have a die hard memory
that
rampup = RAMPUP. It's done this with 3 other variables I made Global
constants and then deleted. Is there a way to stop this from happening?


--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003





Rick Rothstein \(MVP - VB\)

Variable Case issue
 
It's a bug in the Enum function and it's very annoying (we have the same
sort of problem over in the compiled VB world, but it's a little bit worse
over there). Unlike other dimensioning statements in VBA (or compiled VB)
which force the casing used to dimension the variable's name, Enum variable
names take the casing of the last time their variable name was declared
anywhere else (in the compiled VB world, the casing changes to the last time
the Enum's variable was typed, whether inside a dimensioning statement or
not). You can see this with your own situation. Put this code in any code
window...

Sub Test()
Dim RaMpUp as String
End Sub

but make sure you type the variable name (don't just copy it). Now go look
at the variable name in the Enum block. Notice that the casing of the Enum's
variable name has become what was used in the Dim statement of the Test
subroutine. Go back to the Test subroutine and change RaMpUp to rampup this
time; now look at what happened to the variable name in the Enum block.
There is no way to stop this from happening. However, as you can see, you
can "fix" your Enum's variable name casing by putting a Dim statement with
the correct casing somewhere and then deleting it.

Rick



"J Streger" wrote in message
...
I have a sheet where I originally created a global const as:

Global Const RAMPUP = "RU"

Well I decided that rather than that I wanted to do an enumeration. So I
deleted the global const and created:

Public enum TestTypes
RampUp
end enum

Except that after typing VBA gave me this:

Public enum TestTypes
RAMPUP
end enum

In fact, everytime I type rampup in the code it becomes capitalized. I did
a
search and it exists nowhere in my code. Excel doesn't show it in the
object
browser, and I restarted Excel, but it seems to have a die hard memory
that
rampup = RAMPUP. It's done this with 3 other variables I made Global
constants and then deleted. Is there a way to stop this from happening?


--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003



Rick Rothstein \(MVP - VB\)

Variable Case issue
 
It is a known flaw in the VBA Editor (VB6 also) that when you type the
name of an enum member, the enum declaration is changed to match what you
typed rather than the opposite (correct) behavior.


It seems to work a little bit differently in my copy of XL2003. Yes, in VB6,
the last time you type the Enum's member name in any statement, the casing
in the Enum changes to match it; however, in my copy of Excel, that only
seems to happen when I type the Enum's member's name in a dimensioning
statement (such as Dim)... using the member's name in a plain
(non-dimensioning) statement seems to always adopt the Enum's casing.

Rick


J Streger

Variable Case issue
 
Thank you all. And I agree, it is quite a pain.

But at least I can work around it.
--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003



"Rick Rothstein (MVP - VB)" wrote:

It's a bug in the Enum function and it's very annoying (we have the same
sort of problem over in the compiled VB world, but it's a little bit worse
over there). Unlike other dimensioning statements in VBA (or compiled VB)
which force the casing used to dimension the variable's name, Enum variable
names take the casing of the last time their variable name was declared
anywhere else (in the compiled VB world, the casing changes to the last time
the Enum's variable was typed, whether inside a dimensioning statement or
not). You can see this with your own situation. Put this code in any code
window...

Sub Test()
Dim RaMpUp as String
End Sub

but make sure you type the variable name (don't just copy it). Now go look
at the variable name in the Enum block. Notice that the casing of the Enum's
variable name has become what was used in the Dim statement of the Test
subroutine. Go back to the Test subroutine and change RaMpUp to rampup this
time; now look at what happened to the variable name in the Enum block.
There is no way to stop this from happening. However, as you can see, you
can "fix" your Enum's variable name casing by putting a Dim statement with
the correct casing somewhere and then deleting it.

Rick



"J Streger" wrote in message
...
I have a sheet where I originally created a global const as:

Global Const RAMPUP = "RU"

Well I decided that rather than that I wanted to do an enumeration. So I
deleted the global const and created:

Public enum TestTypes
RampUp
end enum

Except that after typing VBA gave me this:

Public enum TestTypes
RAMPUP
end enum

In fact, everytime I type rampup in the code it becomes capitalized. I did
a
search and it exists nowhere in my code. Excel doesn't show it in the
object
browser, and I restarted Excel, but it seems to have a die hard memory
that
rampup = RAMPUP. It's done this with 3 other variables I made Global
constants and then deleted. Is there a way to stop this from happening?


--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003




Andy Pope

Variable Case issue
 
Hi,

The problem is more subtle than just the toggling of case whenever you type
the enum member.

Try this example;
Enter the following at the top of a code module.

'-----------
Const hElLo = 1
Enum XX
hElLo
End Enum
'-----------

Then delete the const and try changing the text to HELLO. It remembers the
const case structure.

Cheers
Andy


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"J Streger" wrote in message
...
I have a sheet where I originally created a global const as:

Global Const RAMPUP = "RU"

Well I decided that rather than that I wanted to do an enumeration. So I
deleted the global const and created:

Public enum TestTypes
RampUp
end enum

Except that after typing VBA gave me this:

Public enum TestTypes
RAMPUP
end enum

In fact, everytime I type rampup in the code it becomes capitalized. I did
a
search and it exists nowhere in my code. Excel doesn't show it in the
object
browser, and I restarted Excel, but it seems to have a die hard memory
that
rampup = RAMPUP. It's done this with 3 other variables I made Global
constants and then deleted. Is there a way to stop this from happening?


--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003

User of MS Office 2003




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com