Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

textbox value doen't change

Status
Not open for further replies.
Mar 31, 2003
22
EU
Sorry,
If this question is ridiously easy ...

' If I click on a button (event) then I can change my textbox value

Private Sub btnClosePort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClosePort.Click
txtSend.Text = "Text value Changed"
End Sub

'But how can I change the data in a textbox for non-events

Public Sub senddata(ByVal s As String)
'doing something with s
'doing something
txtSend.Text = "Value not changed" 'DOES NOT WORK
End Sub


Thanks
 
Everything is event driven. Some event has to happen to change the text. Like:

Code:
Private Sub btnClosePort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClosePort.Click
      senddata("Close Port Clicked")
End Sub

Public Sub senddata(ByVal s As String)
        'doing something with s
        'doing something
        txtSend.Text = s
End Sub

-rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
I understand but it does not overwrite the orignal text in the textbox.
 
You may want to check if the textbox has READONLY property set to true, in which case it will not be overwritten.
 
If setting txtSend.Text = s does not change the value of the text box that means either s contains the same value as txtSend.Text OR the text box you are looking at is not txtSend.

The read only flag will only prevent users from being able to type in the text box, you can still set the text value from code.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
...or the textbox needs to be redrawn.

After changing its text, do an Application.DoEvents.
Code:
txtSend.Text = s
Application.DoEvents
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top