Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default type declaration characters


Visual basic still supports them such as

variableName!
variableName#

and so on

so why are they not popular?. For instance I detest the custom naming
conventions for variables like this:

Dim strMyString as string
strMyString = "hello world"

why not just do this

myString$ = "hello world"

basically visual basic has allowed weak programming to creep into the
language!

Further Quick basic supports this

myString$ = space$(1000) (could be a little out in that syntax)

I don't know if vbasic supports the "space$" keyword
the above code gives the string a definite size. It is not a dynamic
string. I hate dynamic strings. GWbasic had dynamic strings and they
stunk.

Now the basic argument is that vbasic ran out of type declaration
characters as there were more variable types. I don't buy that though.
All vbasic had to do was make some extra custom type declaration chars
and the problem would have been solved. The code would look alot nicer
and neater and the DIM statement would not have to be used to declare
variables at all!!!!

This might agravate some Microsoft employees who like to brag on how
many pages of code they did in one day. With this new idea all
unecessary code could be eliminated . It would reduce the code by about
20 percent.


--
integreat
------------------------------------------------------------------------
integreat's Profile: http://www.excelforum.com/member.php...o&userid=34282
View this thread: http://www.excelforum.com/showthread...hreadid=562187

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default type declaration characters

I'm tempted just to write "de gustibus non disputandum est", since
there's little difference between the methods as long as formal
programming practices are used.

For my money, though, pseudo-Hungarian type variable names are easier to
work with, as the 1-3 letter prefixes are not only easier to remember
than type codes, but I can use prefixes for objects where type
declaration characters don't work:

Dim rOne As Range

or

Dim fntOne As Font

If one explicitly types each variable, the result is no "weaker" (to use
your phrase) than using type declaration characters.

Since I require (using Option Explicit) variables to be declared before
use in order to prevent inadvertent typos from declaring new variables,
I would declare them in a Dim statement anyway. I don't see a great
advantage to

Dim MyString$

over

Dim sMyString As String

and, since type declaration characters don't have to be used in
subsequent code, I see a real advantage in using prefixes. In:

Dim v1$
Dim v2#
v2 = 4
...
v1 = v2

the error is far less apparent to me than

Dim sV1 As String
Dim dV2 As Double
dV2 = 4
...
sV1 = dV2

And for something completely trivial, I find it difficult to take
seriously a system that would declare an Integer as a Percentage:

Dim i% 'Integer!?!


In article ,
integreat
wrote:

Visual basic still supports them such as

variableName!
variableName#

and so on

so why are they not popular?. For instance I detest the custom naming
conventions for variables like this:

Dim strMyString as string
strMyString = "hello world"

why not just do this

myString$ = "hello world"

basically visual basic has allowed weak programming to creep into the
language!

Further Quick basic supports this

myString$ = space$(1000) (could be a little out in that syntax)

I don't know if vbasic supports the "space$" keyword
the above code gives the string a definite size. It is not a dynamic
string. I hate dynamic strings. GWbasic had dynamic strings and they
stunk.

Now the basic argument is that vbasic ran out of type declaration
characters as there were more variable types. I don't buy that though.
All vbasic had to do was make some extra custom type declaration chars
and the problem would have been solved. The code would look alot nicer
and neater and the DIM statement would not have to be used to declare
variables at all!!!!

This might agravate some Microsoft employees who like to brag on how
many pages of code they did in one day. With this new idea all
unecessary code could be eliminated . It would reduce the code by about
20 percent.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default type declaration characters

Perhaps they are not popular because the people who've been doing programming
a while realize the value of Option Explicit. Essentially Option Explicit
forces the use of Dim - and that combination prevents you from may logic
errors that can creep in because of misspelled, unintentional on-the-fly
variable definitions.

Of course, I guess we could go all the way back to the beginning days of
BASIC and restrict variable/constant name lengths to 2 characters plus the
declaration character?

Option Explicit (with the requisite Dim) is more professional, so using it
will make you LOOK more professional.

"integreat" wrote:


Visual basic still supports them such as

variableName!
variableName#

and so on

so why are they not popular?. For instance I detest the custom naming
conventions for variables like this:

Dim strMyString as string
strMyString = "hello world"

why not just do this

myString$ = "hello world"

basically visual basic has allowed weak programming to creep into the
language!

Further Quick basic supports this

myString$ = space$(1000) (could be a little out in that syntax)

I don't know if vbasic supports the "space$" keyword
the above code gives the string a definite size. It is not a dynamic
string. I hate dynamic strings. GWbasic had dynamic strings and they
stunk.

Now the basic argument is that vbasic ran out of type declaration
characters as there were more variable types. I don't buy that though.
All vbasic had to do was make some extra custom type declaration chars
and the problem would have been solved. The code would look alot nicer
and neater and the DIM statement would not have to be used to declare
variables at all!!!!

This might agravate some Microsoft employees who like to brag on how
many pages of code they did in one day. With this new idea all
unecessary code could be eliminated . It would reduce the code by about
20 percent.


--
integreat
------------------------------------------------------------------------
integreat's Profile: http://www.excelforum.com/member.php...o&userid=34282
View this thread: http://www.excelforum.com/showthread...hreadid=562187


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default type declaration characters

Perhaps they are not popular because the people who've been
doing programming
a while realize the value of Option Explicit.


There is absolutely NO reason not to use Option Explicit. I would
be wary of any code that did not require variable declarations.
The probability of misspelled variables names (resulting in a
new, empty variable) is simply too high. Any professional,
commercial-quality code must use Option Explicit.

The same holds of Option Compare Text/Binary. Take your pick
which one to use, but use one of them.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"JLatham" wrote in message
...
Perhaps they are not popular because the people who've been
doing programming
a while realize the value of Option Explicit. Essentially
Option Explicit
forces the use of Dim - and that combination prevents you from
may logic
errors that can creep in because of misspelled, unintentional
on-the-fly
variable definitions.

Of course, I guess we could go all the way back to the
beginning days of
BASIC and restrict variable/constant name lengths to 2
characters plus the
declaration character?

Option Explicit (with the requisite Dim) is more professional,
so using it
will make you LOOK more professional.

"integreat" wrote:


Visual basic still supports them such as

variableName!
variableName#

and so on

so why are they not popular?. For instance I detest the custom
naming
conventions for variables like this:

Dim strMyString as string
strMyString = "hello world"

why not just do this

myString$ = "hello world"

basically visual basic has allowed weak programming to creep
into the
language!

Further Quick basic supports this

myString$ = space$(1000) (could be a little out in that
syntax)

I don't know if vbasic supports the "space$" keyword
the above code gives the string a definite size. It is not a
dynamic
string. I hate dynamic strings. GWbasic had dynamic strings
and they
stunk.

Now the basic argument is that vbasic ran out of type
declaration
characters as there were more variable types. I don't buy that
though.
All vbasic had to do was make some extra custom type
declaration chars
and the problem would have been solved. The code would look
alot nicer
and neater and the DIM statement would not have to be used to
declare
variables at all!!!!

This might agravate some Microsoft employees who like to brag
on how
many pages of code they did in one day. With this new idea all
unecessary code could be eliminated . It would reduce the code
by about
20 percent.


--
integreat
------------------------------------------------------------------------
integreat's Profile:
http://www.excelforum.com/member.php...o&userid=34282
View this thread:
http://www.excelforum.com/showthread...hreadid=562187




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do you type squares or "to the power" in excel?? Hyperyoda Excel Discussion (Misc queries) 4 December 3rd 05 09:57 PM
Select rows and sort based on type Sarah Excel Discussion (Misc queries) 0 October 11th 05 05:06 PM
vlookup argument type tbennett Excel Worksheet Functions 3 September 3rd 05 12:42 AM
multiple results display after filter function Morphyus C via OfficeKB.com Excel Worksheet Functions 1 August 11th 05 03:17 PM
help please - trouble with sumproduct function Jennie Excel Worksheet Functions 2 June 17th 05 09:40 PM


All times are GMT +1. The time now is 01:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"