3

I am working on some VB6 code at work and frequently come across variables, and sometimes numerical values ending with '!'. For example (note the '!' at the end of myVar! and the second 2!:

dist! = Sqr(x ^ 2 + y ^ 2!)

This is a line from the code I am working on. Does the '!' hold any meaning here? I would assume it does, because why use it otherwise, but can't find any documentation on this particular use.

Mike Webb
  • 8,855
  • 18
  • 78
  • 111
  • I believe that it indicates the data type is floating-point (like $ indicates string). But I'm drawing on vague memories of vintage-1980s MBasic, which may not apply at all. – parsifal Sep 14 '11 at 22:50
  • See also [this question](http://stackoverflow.com/questions/4037058/vb-net-exclamation-point) or the documentation! http://msdn.microsoft.com/en-us/library/s9cz43ek(v=VS.100).aspx – MarkJ Sep 15 '11 at 11:18
  • 1
    [What do ! and # mean when attached to numbers in VB6? - Stack Overflow](https://stackoverflow.com/questions/3888921/what-do-and-mean-when-attached-to-numbers-in-vb6) – user202729 Sep 30 '21 at 08:30

1 Answers1

7

It's no an operator, it's a type indicator. An Exclamation/Bang at the end of the name indicates a variable that can hold single precision floating point value. Here's a list of VB type indicators (may not be complete):

$ - string 
% - integer 
& - long integer 
! - single precision floating point
# - double precision floating point 
@ - currency
jdigital
  • 11,926
  • 4
  • 34
  • 51