Question

So I'm learning VB.NET and I kinda have this newbie question and I couldn't find answers anywhere on the web.

The program

This program is supposed to be counter. Every time the button is clicked the label should update. Here's my code for the MouseClick Listener every time the button is clicked:

Sub Button2MouseClick(sender As Object, e As MouseEventArgs)
    Dim starter As String
    Dim int1 As Integer 
    Dim int2 As Integer 
    Dim ender As String
    starter =label2.Text
    int1 = CInt(starter)
    int2 = (int1 + 1)
    ender = CStr(int2)
    label2.Text = ender
End Sub

The program works but here's the problem. It only works up until number 9. Once it is supposed to display "10" is just displays 1 and when it is supposed to display 11, 12, 13, 14, 15, 16, 17, 18, and 19, it only displays "1" (the first digit).

Was it helpful?

Solution

I'd suggest that probably, the issue is that you've sized the label control so that it can only show a single digit.

If you go back to the form designer and make that label control bigger, you should start to be able to see the second digit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top