Display a variable in a TextBox - Simple task if I new how

In the absence of reference materials which are still somewhere over the Pacific, I'm trying to teach myself how to implement the simplest tasks without much luck.

I have created a form and on that form have placed a TextBox. Now I go to the underlying code for this control and want to display a type LONG variable in the TextBox.

Two issues here: the TextBox will not display a Long variable; this I have apparently overcome using ToString. But how do I get the resultant variable text data into the TextBox control on the form No, I don't want to use MsgBox!

Like that other large Corporation (whose name will not be mentioned), you will only find what you want in the documentation if you know precisely what to search for; in my case the name of the function to accomplish the task. 

Hope there is someone out there who can help this dummy.

 

 

 

 



Answer this question

Display a variable in a TextBox - Simple task if I new how

  • chris can surf

    hi,

    the best thing is to post part of your code, anyway here its a form that contain 3 textbox and a button the first 2 textboxs display the long variables

    the third textbox will convert the textbox to long and calculate it and display it as text when you click on the button

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

    Dim var1, var2 As Long

    var1 = 44646467687546

    var2 = 64643216876432

    TextBox1.Text = var1.ToString

    TextBox2.Text = var2.ToString

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    TextBox3.Text = (Long.Parse(TextBox1.Text) + Long.Parse(TextBox2.Text)).ToString

    End Sub

    hope it was helpfull



  • wgkwvl

    When using MSDN, generally all you need to know is the name of the class you want to affect.  If you want to do something to or with a TextBox you would serach for "TextBox class", which will give you the help topic for the class overview very high in the list, or "TextBox members", which will give you the help topic for the member listing high in the list.  Either or noth of those would have led you to the Text property very quickly.  Now you know for future reference.  This won't help in all situations, but it will in most.

  • Ted69

    Thank you Shakalama, your code construct:

     "TextBox1.Text = Var1.ToString", was what I was after.

    I tried this, but the TextBox remained empty when I ran the application. Then I realised I had the code in the TextBox1.Text_Changed sub, created by Designer and that it should be triggered (in this case) by the Load Event. A few tweaks to my code and it's running fine now. Many thanks pal.

    Coincidentally, my reference books have just this minute arrived from Amazon!

    Why does it always happen to me this way lol

     


  • Maarten van Stam

    Hey, awesome post thanks.....How do I grab out the text when it is changed by the user and throw it into an integer..I think this is along the same lines. Thanks
  • kim aldis

    hi, Allen

    you are most wellcome

    best regards



  • Display a variable in a TextBox - Simple task if I new how