Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I apologize up front if this is a really dumb question.
My procedure [1 module/1 sub/900 lines (no comments)] involves 57 dim statements. Lots of variables, but it runs great. It just looks strange with all the Dim statements. Is that too many? Is it bad coding practice? Any tips to do handle it better? Thank you, Robert |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
57 variables in 900 lines sounds like a lot, but without seeing your
code, it's hard to say whether it's too many. If the code is for your use only, my philosophy is usually "if it runs the way you want, it's correct". If the code will need to be maintained by others, you're better off using a more formal system. One shortcut, which I usually don't recommend, but can save a lot of Dim'g is to use a DefType statement. For instance, at the module level, putting DefStr S will automatically type all variables starting with "s" or "S" as strings, so Dim sOne, sTwo, sThree, sFour is equivalent to Dim sOne As String Dim sTwo As String Dim sThree As String Dim sFour As String or Dim sOne As String, sTwo As String, sThree As String, sFour As String In article , "Robert Lerner" wrote: My procedure [1 module/1 sub/900 lines (no comments)] involves 57 dim statements. Lots of variables, but it runs great. It just looks strange with all the Dim statements. Is that too many? Is it bad coding practice? Any tips to do handle it better? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That would work well for me because I have always used those very prefixes.
Great tip. Thanks. -Robert "JE McGimpsey" wrote in message ... 57 variables in 900 lines sounds like a lot, but without seeing your code, it's hard to say whether it's too many. If the code is for your use only, my philosophy is usually "if it runs the way you want, it's correct". If the code will need to be maintained by others, you're better off using a more formal system. One shortcut, which I usually don't recommend, but can save a lot of Dim'g is to use a DefType statement. For instance, at the module level, putting DefStr S will automatically type all variables starting with "s" or "S" as strings, so Dim sOne, sTwo, sThree, sFour is equivalent to Dim sOne As String Dim sTwo As String Dim sThree As String Dim sFour As String or Dim sOne As String, sTwo As String, sThree As String, sFour As String In article , "Robert Lerner" wrote: My procedure [1 module/1 sub/900 lines (no comments)] involves 57 dim statements. Lots of variables, but it runs great. It just looks strange with all the Dim statements. Is that too many? Is it bad coding practice? Any tips to do handle it better? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
dimming text | Excel Discussion (Misc queries) | |||
Dimming Controls | Excel Programming |