Number Counter

 

I have been answering questions pertaining to Visual Basic under the Yahoo! Answer section lately. So far I have three answers chosen as the best answers. Today I answered  another VB question that goes like this "

Help Me With Visual Basic 6 regarding String Variables... Please....?

I have a question about String Variables like the program:

My problem is that...

There is an Input(TextBox) Which you enter numbers then there is an output(Label) Which will show that how many number 3 is input in the label...

 Below is the solution for the above question:

 

Private Sub Form_Load()
Form1.Show

Dim num As String, counter As Integer

Do
num = InputBox("Enter a Number between 0 and 9 or Enter End to stop")
If Val(num) = 3 Then
counter = counter + 1
Label1.Caption = Str(counter)

End If

Loop Until num = "End"

End Sub

 

Explanation

In this program, I let the user enter a series of numbers between 0 and 9 through an input box. He can terminate the process by entering the "End" word.

The program that check whether a number 3 is entered or not, if the number is a number, it is then counted with a counter. The counter is displayed on Label1.

 

The run time screen shot

 

 

 

 

 

 

 [Back to VBToday]