In: Computer Science
Write a program that given a number entered through a cell, say if it is positive or not positive.
programming language is VB8
Here i am writing simple code to check whether a number is
positive or not using VisualBasic
Method1 - Input using Console
Module Checknumber
Sub main()
Dim Num As Integer
Console.Write("Enter a
number greater to check if it is positive or not: ")
Num =
Console.ReadLine
If Num > 0 Then
Console.WriteLine(" The entered number is a positive number")
Else
Console.WriteLine(" The entered number is not a positive number
")
End If
Console.ReadKey()
End Sub
End Module
Method 2 - Input using button
Private Sub Command1_Click()
Dim a as Single
a = val(Text1.Text)
if(a>0) then
Label2.Caption=a& " is a positive number"
Elseif(a<0) then
Label2.caption = a& " is not a positive number"
Else
Label2.caption= a& " is a equal number"
End if
End Sub
Note - Do not forget to declare Lablel1 and Text1
If you find any difficulty while running the code, Please comment
in the comment section
Thank you!