Hello, im new at vb.net, what im trying to do is that textbox3 and texbox5 have a data, and i want to make a "compare" button, when i click it, it will collor they data diffrences with red, colored data will be shown in texbox3. the code from vb6(this codes works well btw):
Private Sub Command5_Click()
Dim a As Integer
Dim R1 As String
Dim r2 As String
Dim strimm As String
strimm = RichTextBox1.Text
RichTextBox1 = Replace(strimm, vbCrLf, "")
strimm = RichTextBox2.Text
RichTextBox2 = Replace(strimm, vbCrLf, "")
For a = 0 To Len(RichTextBox2)
RichTextBox1.SelStart = a
RichTextBox1.SelLength = 1
R1 = RichTextBox1.SelText
RichTextBox2.SelStart = a
RichTextBox2.SelLength = 1
r2 = RichTextBox2.SelText
If R1 <> r2 Then
RichTextBox1.SelColor = vbRed
End If
Next
End Sub
What I have tried:
The code i tried in VB.net( it colores whole data with red, if only 1 is not eqaul, thats an error, i need to only diffrence data colored):
Private Sub Command5_Click(sender As Object, e As EventArgs) Handles Command5.Click
Dim a As Integer
Dim R1 As String
Dim r2 As String
Dim strimm As String
strimm = TextBox3.Text
TextBox3.Text = Replace(strimm, vbCrLf, "")
strimm = TextBox5.Text
TextBox5.Text = Replace(strimm, vbCrLf, "")
For a = 0 To TextBox5.TextLength
TextBox3.SelectionStart = a
TextBox3.SelectionLength = 1
R1 = TextBox3.SelectedText
TextBox5.SelectionStart = a
TextBox5.SelectionLength = 1
r2 = TextBox5.SelectedText
If R1 <> r2 Then
TextBox3.ForeColor = Color.Red
End If
Next
End Sub