what is the meaning of the dollar sign after a method name in vb.net
like this:
Replace$("EG000000", "0", "")
what is the meaning of the dollar sign after a method name in vb.net
like this:
Replace$("EG000000", "0", "")
Old type notifier - see this
Some other old ones:
& -> Long
% -> Integer
# -> Double
! -> Single
@ -> Decimal
$ -> String
Still exist in VB.Net for the sake of backward compatibility...
In "classic" VB, there were two versions of the built in-string functions. Let me use Left
as an example:
Left(s, length)
takes a variant as the first parameter and returns a variant.Left$(s, length)
takes a string as the first parameter and returns a string.This distinction still exists in modern-day VBA.
I suspect that the reason behind this is that strings in VBA cannot be Null
(note that Null <> ""
). Thus, when dealing with nullable database fields, you had to use variant variables. Variant variables can take any value, including all of the integral values (strings, integers, ...) as well as some special values such as Null
, Empty
or Missing
. The non-$ functions allowed you to use variants as input and get variants as output. For example, Left(Null, ...)
returns Null
.
In VB.NET, this distinction is no longer necessary: The non-$ functions do exactly the same as the $ functions, which are kept only for backwards compatibility with old code.
VBA
reference. –
Rosabella What Heinzi said and to clear up the type character business
Dim s$ = "FooBar" 'dim s as String = "FooBar"
Dim r As String
Stop
r = Replace$(s, "Bar", "")
'.Net equivalent
r = s.Replace("Bar", "")
© 2022 - 2024 — McMap. All rights reserved.