Hi Kira Qian,
If I set property Scrollbar to Vertical on multiline TextBox,I cant insert button on Verical scrollbar.
My basic requirment is to develop an Active X control to edit text in multiline TextBox. For thatone I need a multiline TextBox, Vertical scrollbar and a Button. When User click on theButton, one form will be open .
User canedit text on the form. If he click Ok button onthe form , changes will be reflected to multiline textbox. If he clickCancel on the Form changes will not be reflected to multiline TextBox.
Here is the Code for Usercontrol:-
Private oForm As Form1
Private lineCount As Integer
Private MaxLineCount As Integer
Private Sub Command1_Click()
oForm.Text2.Text = Text1.Text
oForm.strText = Text1.Text
oForm.Show vbModal
Text1.Text = oForm.Text2.Text
End Sub
Private Sub Text1_Change()
lineCount = Len(Text1.Text) - Len(Replace(Text1.Text, vbCrLf, vbCr))
If lineCount - MaxLineCount > 0 Then
VScroll1.Enabled = True
Else
VScroll1.Enabled = False
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If (Text1.SelStart < VScroll1.Max) And VScroll1.Enabled = True Then
VScroll1.Value = Text1.SelStart
End If
End Sub
Private Sub UserControl_Initialize()
VScroll1.Max = (VScroll1.Height - Text1.Height) + 1000
VScroll1.SmallChange = 50
VScroll1.LargeChange = 100
MaxLineCount = 2
VScroll1.Enabled = False
Set oForm = New Form1
End Sub
Private Sub UserControl_Terminate()
Set oForm = Nothing
End Sub
Private Sub VScroll1_Change()
Text1.SelStart = VScroll1.Value
End Sub
Private Sub VScroll1_Scroll()
'Text1.SelStart = VScroll1.Value
End Sub
Here is the Codefor Form:-
Public strText As String
Private Sub Cancel_Click()
Text2.Text = strText
Me.Hide
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then
Call Cancel_Click
End If
End Sub
Private Sub OK_Click()
Me.Hide
End Sub
Private Sub Text2_GotFocus()
strText = Text2.Text
End Sub
Here implementation for Vscroll is not proper. Could you please help me to implement Vertical Scroll functionality.Remember that I amusing seperate Vertical Scroolbar to scroll the text.
Please help me if you know the functionality of Vertical Scrollbar.
Thanks
Manohar Rudra