locked
read from textbox on click event RRS feed

  • Question

  • hi folks,

    im trying to read value entered in textbox on click event but its not working.

    its sounds simple but Im new to blend , hence please give me a code to do the same.

    regards

    cherian

    Tuesday, December 11, 2012 8:11 AM

Answers

  • Hello justin_cherian,

    hi folks,

    im trying to read value entered in textbox on click event but its not working.

    its sounds simple but Im new to blend , hence please give me a code to do the same.

    regards

    cherian

    Blend in what sense? If you're referring to blend espression you're on the wrong forum, but if it wants to manage the content within a textbox control can do this, a simple example, put this code in a click event of a pulsnate

    MessageBox.Show (TextBox1.Text)

    where the Text property of the TextBox control, inside the messagebox displays its value, but if you're new to VisualBasic advice before you get to write code to start with a textbook.

    Regards.


    Tuesday, December 11, 2012 11:50 AM
  • Hi Charian,

    as Carmelo described it is not really difficult to handle the text of a textbox in another control.
    What exact is your problem. I struggled about the word "value". Often beginners start an application with an calculator or a similar function.

    Mostly the programmer use a wrong type of variable e.g. String instead Integer or Double.
    So if you user String variable and add 2  +  2 you'll receive 22 as result instead of 4.
    The code sample below explains the differenr and shows how to take over a text from one control or result to another control.

    Hope this can help.

    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.Button1.Text = "Result"
            Me.Button2.Text = "Addition"
            Me.Button3.Text = "wrong"
    
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Try
                Dim FirstVal As Double = Me.TextBox1.Text
                Dim SecondVal As Double = Me.TextBox2.Text
                Dim Information As String = Me.TextBox3.Text
                Dim Result As Double
                Result = FirstVal / SecondVal
                Me.Label1.Text = Result & " " & Information
            Catch ex As Exception
                MsgBox("No input", MsgBoxStyle.Critical)
                TextBox1.Focus()
            End Try
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Try
                Dim FirstVal As Double = Me.TextBox1.Text
                Dim SecondVal As Double = Me.TextBox2.Text
                Dim Information As String = Me.TextBox3.Text
                Dim Result As Double
                Result = FirstVal + SecondVal
                Me.Label1.Text = Result & " " & Information
            Catch ex As Exception
                MsgBox("No input", MsgBoxStyle.Critical)
                TextBox1.Focus()
            End Try
        End Sub
    
        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            Try
                Dim FirstVal As String = Me.TextBox1.Text
                Dim SecondVal As String = Me.TextBox2.Text
                Dim Information As String = Me.TextBox3.Text
                Dim Result As Double
                Result = FirstVal + SecondVal
                Me.Label1.Text = Result & " " & Information
            Catch ex As Exception
                MsgBox("No input", MsgBoxStyle.Critical)
                TextBox1.Focus()
            End Try
        End Sub
    End Class


    Liebe Grüße Stefan | Cheers Stefan I'm using VB 2008 and VB 2010 Express Be a good forum member - mark posts that contain the answers to your questions or those that are helpful. c# in vb Translator: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Thursday, December 13, 2012 9:12 AM

All replies

  • Hello justin_cherian,

    hi folks,

    im trying to read value entered in textbox on click event but its not working.

    its sounds simple but Im new to blend , hence please give me a code to do the same.

    regards

    cherian

    Blend in what sense? If you're referring to blend espression you're on the wrong forum, but if it wants to manage the content within a textbox control can do this, a simple example, put this code in a click event of a pulsnate

    MessageBox.Show (TextBox1.Text)

    where the Text property of the TextBox control, inside the messagebox displays its value, but if you're new to VisualBasic advice before you get to write code to start with a textbook.

    Regards.


    Tuesday, December 11, 2012 11:50 AM
  • Hi Charian,

    as Carmelo described it is not really difficult to handle the text of a textbox in another control.
    What exact is your problem. I struggled about the word "value". Often beginners start an application with an calculator or a similar function.

    Mostly the programmer use a wrong type of variable e.g. String instead Integer or Double.
    So if you user String variable and add 2  +  2 you'll receive 22 as result instead of 4.
    The code sample below explains the differenr and shows how to take over a text from one control or result to another control.

    Hope this can help.

    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.Button1.Text = "Result"
            Me.Button2.Text = "Addition"
            Me.Button3.Text = "wrong"
    
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Try
                Dim FirstVal As Double = Me.TextBox1.Text
                Dim SecondVal As Double = Me.TextBox2.Text
                Dim Information As String = Me.TextBox3.Text
                Dim Result As Double
                Result = FirstVal / SecondVal
                Me.Label1.Text = Result & " " & Information
            Catch ex As Exception
                MsgBox("No input", MsgBoxStyle.Critical)
                TextBox1.Focus()
            End Try
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Try
                Dim FirstVal As Double = Me.TextBox1.Text
                Dim SecondVal As Double = Me.TextBox2.Text
                Dim Information As String = Me.TextBox3.Text
                Dim Result As Double
                Result = FirstVal + SecondVal
                Me.Label1.Text = Result & " " & Information
            Catch ex As Exception
                MsgBox("No input", MsgBoxStyle.Critical)
                TextBox1.Focus()
            End Try
        End Sub
    
        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            Try
                Dim FirstVal As String = Me.TextBox1.Text
                Dim SecondVal As String = Me.TextBox2.Text
                Dim Information As String = Me.TextBox3.Text
                Dim Result As Double
                Result = FirstVal + SecondVal
                Me.Label1.Text = Result & " " & Information
            Catch ex As Exception
                MsgBox("No input", MsgBoxStyle.Critical)
                TextBox1.Focus()
            End Try
        End Sub
    End Class


    Liebe Grüße Stefan | Cheers Stefan I'm using VB 2008 and VB 2010 Express Be a good forum member - mark posts that contain the answers to your questions or those that are helpful. c# in vb Translator: http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Thursday, December 13, 2012 9:12 AM