All source code is downloaded here: http://www.up2e.com/resource.php
Try a writing board with VB.NET (3) --- by zigz (Luhai) Luluhai@eastday.com
3) About finding the replacement function Here I use a PANEL panel control to find the next, replace buttons, and text boxes. Figure 4 finds replacement I don't need a form? Because I just want to practice the code to drag the control, I can implement the panel to drag in the main form range. Since I saw an foreigner tutorial, I translated it to practice exercises. First talk about this simple lookup replacement function, the user enters the word you want to find in the first text box, then click the Find button, the program will find the matching word in RichTextBox, after finding it, highlight it , Click the next button, you will find the next match. . This is repeated until it ends, and the replacement is to replace all the contents of the first text box in the RichTextBox in the second text box. Is it some winding? Still trying to try it. Here is to find replacement related code (mainly to create a FindText function):
'About implementation lookup function
DIM MyPOS AS Integer 'Declaration a global variable
Private Sub FindText (Byval Start AS Integer) Creates a FindText function
DIM POS AS INTEGER
DIM Target As String
'Get the string you want to find by the user
Target = txtbox.text
POS = INSTR (Start, RTBOX.TEXT, TARGET)
If POS> 0 Then 'found matched strings
MyPOS = POS
RTBOX.SELECTIONSTART = MYPOS - 1 'highlight display
RTBOX.SerectionLength = len (txtbox.text)
RTBOX.FOCUS ()
Else
Msgbox ("Didn't find!")
END IF
End Sub
Give the Find button, the FindNext button
Private sub find_click (byval sender as system.object, byval e as system.eventargs) Handles Find.click
Findtext (1)
End Sub
Private sub findnext_click (Byval e as system.EventArgs) Handles Findnext.click
Findtext (MYPOS 1)
End Sub
Drag the code for the control:
'The following procedure is used as a drag "lookup panel"
Dim Dragging as boolean
Dim Mousex as INTEGER
Dim Mousey as integer
Private Sub Panel1_MouseDown (Byval e as system.windows.forms.mouseeventargs) Handles Panel1.MouseDown
If E.BUTTON = MouseButtons.Left Then
Dragging = true
Mousex = -e.x
mousey = -e.y
DIM Clipleft as integer = me.pointtoclient (mousePosition) .x - panel1.location.xdim cliptop as integer = me.pointtoclient (mouseposition) .y - panel1.location.y
DIM CLIPWIDTH AS INTEGER = Me.ClientSize.width - (Panel1.Width - Clipleft)
DIM Clipheight as integer = me.clientsize.height - (Panel1.Height - Cliptop)
Cursor.Clip = Me.Rectangletoscreen (New Rectangle (Clipleft, Cliptop, Clipwidth, ClipHeight))
Panel1.invalidate ()
END IF
End Sub
Private Sub Panel1_Mousemove (Byval e as system.windows.forms.mouseeventargs) Handles Panel1.Mousemove
IF Dragging Then
'Moving controls to a new location
DIM MPSITION As New Point ()
MPSITION = me.pointtoclient (mouseposition)
MPosition.offset (Mousex, Mousey)
'Do not leave the main window
Panel1.Location = MPSITION
END IF
End Sub
Private Sub Panel1_Mouseup (Byval e as system.windows.forms.mouseeventargs) Handles Panel1.Mouseup
IF Dragging Then
'End drag
Dragging = false
Cursor.clip = Nothing
Panel1.invalidate ()
END IF
End Sub is not complete ...