Adding multiple numbers to textbox

Hey guys, I'm looking to add multiple numbers to a textbox. Like for example, say I have three buttons button1.text = 1, button2.text = 2, and button3.text=3. What I'm wondering is how to get all those numbers in the textbox without having to erase the previous number I clicked on. For example: If I press button1 I want the textbox to show 1, then if I decide to press button 3, I want the textbox to show 13.


Answer this question

Adding multiple numbers to textbox

  • Sampat

    Great! It works! Does the sender.text grab the value of whatever button is being pressed

  • afroblanco

    Try

    button1.text &= NewNumber.ToString



  • Sarwanan

    the sender object will be one of the three buttons

    because this

         Handles Button1.Click, Button2.Click, Button3.Click

    its means thes prucedur will be called when one the events hass been raised

    Button1[object]  Click[event]     ' Button1.Click   sender = Button1 

    Button2[object]  Click[event]     ' Button2.Click   sender = Button2

    Button3[object]  Click[event]     ' Button3.Click   sender = Button3

     


  • Fabio Reynoso

    Here's some example code doing the task

    Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.Button1.Text = 1
    Me.Button2.Text = 2
    Me.Button3.Text = 3
    End Sub

    Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click
    Me.TextBox1.Text = Me.TextBox1.Text & sender.text
    End Sub
    End Class


  • Adding multiple numbers to textbox