How to count textbox value whit 0.1


  • Here is my code:

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
            OrainsTextBox2.Text = Val(OrainsTextBox2.Text) + 0.1
        End Sub

    But did not work

    Plase help me!

    Sunday, March 19, 2017 6:30 PM

All replies


    if ISnumeric OrainsTextBox2.Text then OrainsTextBox2.Text = Cstr(Cdec(OrainsTextBox2.Text) + 0.1)


    Sunday, March 19, 2017 6:56 PM
  • Try this

    Public Class Form1
        Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
            Dim value As Decimal = 0
            If Decimal.TryParse(OrainsTextBox2.Text, value) Then
                value += 0.1D
                OrainsTextBox2.Text = value.ToString
            End If
        End Sub
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            OrainsTextBox2.Text = "0"
        End Sub
    End Class

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Sunday, March 19, 2017 8:00 PM