Asked By
BubAngus5
20 points
N/A
Posted on - 06/07/2012
How to write a program that will ask the user to enter a number then the program will determine if the number is positive or negative then also determine if the number is in ones, tens, hundreds, thousands or millions place. Also a label control can be used instead of a message box.
Write a simple visual basic 6.0 program
Just proceed to the Code editor Window or you have to double click the control concerned to design your program code. The following codes will be used.
—————————————–Enter button——————Â
 Private Sub Command1_Click()
Dim x As Double
If CInt(Text1.Text) < 0 Then           'check if + or –
   Label2.Caption = "Number is Negative…"
Else
   Label2.Caption = "Number is Positive…"
End If
x = Len(Text1.Text)                            'count nos.
If CInt(Text1.Text) < 0 Then x = x – 1         'remove negative
If x = 1 Then
   Label3.Caption = "Number is in ONES…"
ElseIf x = 2 Then
   Label3.Caption = "Number is in TENS…"
ElseIf x = 3 Then
   Label3.Caption = "Number is in HUNDREDS…"
ElseIf x = 4 Then
   Label3.Caption = "Number is in THOUSAND…"
ElseIf x = 5 Then
   Label3.Caption = "Number is in MILLIONS…"
'Add more if you want
End If
End Sub
—————————————–Clear button——————Â
Private Sub Command2_Click()
Text1.Text = ""
Label2.Caption = ""
Label3.Caption = ""
End Sub
—————————————–Exit button——————
Private Sub Command3_Click()
End
End Sub
—————————————–
I have included an attachment photo which you can view as your reference. The picture is the actual coding I used.