View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default How do I trapped the error and optimize the code?

I had completely forgotten that VB contained DefType statements... I
probably haven't used them since VB3 (the compiled version of VB from around
the early to mid 1990s); and I only used them then because I had some
programs in Fortran IV (which had a similar variable declaration statements)
from our DEC mini-computer which I needed to implement on our IBM personal
computers when we switched over to them. Now that I have been reminded of
their existence, and have given careful thought on them, I will not consider
ever using them in my programs and I will promptly try to forget about their
existence once again.<g

--
Rick (MVP - Excel)


"JE McGimpsey" wrote in message
...
And to get completely esoteric, the exception to Rick's excellent
explanation is that you *can* have Def<type statements in the module. I
rarely see this, but you can put this at the top of your code module:

DefLng L-N
DefStr S

Then

Public Sub try2()
Dim sString
Dim nLong
MsgBox TypeName(sString) & vbNewLine & TypeName(nLong)
End Sub






In article ,
"Rick Rothstein" wrote:

Unlike lots of other languages, in VB, every variable must be
declared as to Type individually; otherwise, if it isn't, that
variable is then declared as the default data Type which, in VB, is a
Variant.