Results 1 to 3 of 3

Thread: Problem with writing a code to clear the result for TextBoxes using TextChanged

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2012
    Posts
    6

    Problem with writing a code to clear the result for TextBoxes using TextChanged

    Hi All,

    I am a newbie to VB. I use Visual Basic 2010. I am trying to build a basic Average Calculator Application. I can make the application calculate the average.
    However, I am unable to write the code to clear the resultLabel after the user enters new input into any of the TextBoxes. Could anyone please help and point me to the right direction here? Below is my codes:

    Public Class AverageCalculator

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim number1 As Integer
    Dim number2 As Integer
    Dim number3 As Integer
    Dim total As Integer
    Dim average As Integer

    number1 = TextBox1.Text
    number2 = TextBox2.Text
    number3 = TextBox3.Text

    total = number1 + number2 + number3
    average = total / 3
    resultLabel.Text = average

    End Sub

    'clear result
    Private Sub TexBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    resultLabel.clear()

    End Sub

    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
    resultLabel.clear()

    End Sub

    Private Sub Textbox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
    resultLabel.Clear()
    End Sub

    End Class

    Thanks in advance!
    TheZealous
    Last edited by TheZealous; Sep 9th, 2012 at 03:48 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width