Click here to Skip to main content
15,886,075 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm new in vb.net, came from vb6, so the problem is that i cant do this
RichTextBox = Richtextbox1.text 
like i did in vb6, so basicly RTB get value from a buffer then i want move this value from RTB to RTB1, thanks a lot

What I have tried:

RichTextBox = Richtextbox1.text
Posted
Updated 17-Mar-17 17:38pm
Comments
[no name] 17-Mar-17 22:04pm    
So your question is, how to set the Text property of a TextBox?
JeezyWonder 17-Mar-17 22:32pm    
I need text proprety of one textbox move to another, i tried RichTextBox.Text = RichTextBox1.text, it doesnt work
Ralf Meier 18-Mar-17 8:20am    
That should work ...
Under which condition did you tried it ...
You should give us more information ...
[no name] 18-Mar-17 9:18am    
It DOES work. And telling us "it doesn't work" is meaningless to us.
JeezyWonder 19-Mar-17 18:08pm    
Im using dataeventhandler,

Private Sub SerialPort1_DataReceived(sender As Object, e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
ReceivedText(SerialPort1.ReadExisting())
End Sub
Private Sub ReceivedText(ByVal [text] As String)
If Me.TextBox3.InvokeRequired Then
Dim x As New SetTextCallBack(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
Me.TextBox3.Text &= [text]

TextBox3.Text = TextBox7.Text

End If
End Sub

1 solution

You're talking about the Default Property of the old RichTextBox control in VB6. The concept still exists in VB.NET but not really used in the controls. It's is FAR better to explicitly specify the property .Text instead of relying on knowing what the default property is.
VB.NET
OtherRichTextBox.Text = RichTextBox1.Text
 
Share this answer
 
Comments
JeezyWonder 18-Mar-17 2:51am    
I tried it but nothing. RichTextBox1.Text get data from buffer, then it should move that data to OtherRichTextBox.
Dave Kreskowiak 18-Mar-17 10:24am    
OK, there's something you're not telling us. Without seeing the code and what the variables are defined as it's impossible to tell you what you're doing wrong.
JeezyWonder 19-Mar-17 18:07pm    
Im using dataeventhandler,

Private Sub SerialPort1_DataReceived(sender As Object, e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
ReceivedText(SerialPort1.ReadExisting())
End Sub
Private Sub ReceivedText(ByVal [text] As String)
If Me.TextBox3.InvokeRequired Then
Dim x As New SetTextCallBack(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
Me.TextBox3.Text &= [text]

TextBox3.Text = TextBox7.Text

End If
End Sub
Dave Kreskowiak 19-Mar-17 18:35pm    
Get rid of the last line, TextBox3.Text = TextBox7.Text.

Your code appends the data received from the SerialPort to TextBox3 and then immediately replaces the contents of TextBox3 with whatever is in TextBox7.

Your controls should REALLY be renamed to something more useful than the default names. TextBox3 and TextBox7 don't describe what these controls are supposed to be fore.

Also, there isn't a single reference in this code to a RichTextBox anywhere.

Your questions don't make any sense in the context of the code you just posted.
JeezyWonder 19-Mar-17 19:23pm    
Thanks, it works, Private Sub ReceivedText(ByVal [text] As String)
If Me.TextBox7.InvokeRequired Then
Dim x As New SetTextCallBack(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
Me.TextBox7.Text &= [text]
' Me.TextBox3.Text &= [text]
TextBox3.Text = TextBox7.Text

End If
End Sub


btw whole code from vb6 which i transfered to vb.net is:

Private Sub MSComm1_OnComm()
Dim Buffer As String
Select Case MSComm1.CommEvent
Case comEvReceive

Buffer = MSComm1.Input
Text1.Text = Text1.Text & Buffer

End Select
RichTextBox1 = Text1.Text
RichTextBox1.SelStart = Len(RichTextBox1.Text)
End Sub


Do i need this RichTextBox1.SelStart = Len(RichTextBox1.Text)??? This MsCOmm and dataeventhandler diffrences so huge

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900