Skip to Content
VB.NET Language in a Nutshell, Second Edition
book

VB.NET Language in a Nutshell, Second Edition

by Steven Roman PhD, Ron Petrusha, Paul Lomax
April 2002
Intermediate to advanced
688 pages
19h 51m
English
O'Reilly Media, Inc.
Content preview from VB.NET Language in a Nutshell, Second Edition

Name

Sign Function

Class

System.Math

Syntax

Sign(value)
value (required; any numeric type, including Decimal)

A numeric expression

Return Value

Integer

Description

Determines the sign of a number

Rules at a Glance

The return value of the Sign function is determined by the sign of value, as follows:

If number is

Sign returns

Positive

1

Zero

0

Negative

-1

Programming Tips and Gotchas

  • Sign is useful in cases in which the sign of a quantity defines the sign of an expression. For example:

    lngResult = lngQty * Sgn(lngValue)
  • This is a Shared member, so it can be used without creating any objects.

  • If you are using the Sign function to evaluate a result to False (0) or True (any nonzero value), you could use the CBool function instead.

  • A major use for Sign is to determine the sign of an expression.

VB.NET/VB 6 Differences

The name of this function has changed. In VB 6, it is named Sgn. In VB.NET, it is named Sign and is a member of the Math class of the System namespace.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

VB .NET Language in a Nutshell

VB .NET Language in a Nutshell

Steven Roman PhD, Ron Petrusha, Paul Lomax

Publisher Resources

ISBN: 0596003080Supplemental ContentCatalog PageErrata