How to find the sign of a number VB.NET

1 Answer

0 votes
Imports System

Public Class Program
    Public Shared Sub Main()
       Dim num As Integer = -7483

        Dim result As Integer = Math.Sign(num)
 
        If result < 0 Then
            Console.WriteLine("- negative")
        ElseIf result > 0 Then
            Console.WriteLine("+ positive")
        Else
            Console.WriteLine("zero")
        End If
        
    End Sub
End Class




' run:
'
' - negative
'

 



answered Dec 17, 2023 by avibootz
edited Mar 6, 2024 by avibootz
...