Upgrading VB6 Richtextbox


 Recieved the following question:


 



Can anyone tell me what to use as a work around for the span and upto methods in VB6. These seem to be missing in VB.NET


The First chunk of code below is VB6 filling a richtextbox called rtbEdit; the keyup event is finding the string zzzzzzzzz and highlighting it -below that is the same code but in VB.NET


Hope this helps somebody!


-Chuck


 


 


 


Private Sub Form_Load()


For i = 1 To 10


 rtbEdit.Text = rtbEdit.Text + “Hello ” + vbCrLf


Next


 rtbEdit.Text = rtbEdit.Text + “zzzzzzzzz”


End Sub


 


Private Sub rtbEdit_KeyUp(KeyCode As Integer, Shift As Integer)


     rtbEdit.UpTo “zzzzzzzzz”, True, False


     rtbEdit.Span “zzzzzzzzz”


 End Sub


 


 


 


 


 


Private Sub rtbEdit_KeyUp(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyEventArgs) Handles rtbEdit.KeyUp


            Dim KeyCode As Short = eventArgs.KeyCode


            Dim Shift As Short = eventArgs.KeyData \ &H10000


            ‘UPGRADE_WARNING: UpTo was upgraded to SelectionStart and has a new behavior. Click for more: ‘ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword=”9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7″‘


            rtbEdit.SelectionStart = rtbEdit.Find(“zzzzzzzzz”, System.Windows.Forms.RichTextBoxFinds.None)


            ‘UPGRADE_WARNING: Span was upgraded to Find and has a new behavior. Click for more: ‘ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword=”9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7″‘


            rtbEdit.Find(“zzzzzzzzz”)


      End Sub


 


Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load


            Dim i As Object


            For i = 1 To 10


                  rtbEdit.Text = rtbEdit.Text & “Hello “ & vbCrLf


            Next


            rtbEdit.Text = rtbEdit.Text & “zzzzzzzzz”


      End Sub


Comments (0)