Write a simple visual basic 6.0 program

Asked By 20 points N/A Posted on -

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.

Program will determine if the number is positive or negative
Answered By 0 points N/A #160536

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.

code and design.png

—————————————–Enter button—————— 

 Private Sub Command1_Click()

Dim x As Double

If CInt(Text1.Text) < 0 Then                    'check if + or –

    Label2.Caption = "Number is Negative…"


    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 Sub


I have included an attachment photo which you can view as your reference. The picture is the actual coding I used.

Login/Register to Answer

Related Questions