我在VBA中的文本框默认滚动到底部。我不想要这个。我希望滚动条在显示用户窗体时保持在顶部。
解?
答案 0 :(得分:4)
在UserForm的Initialize
事件中,使用.SelStart
例如。
Private Sub UserForm_Initialize()
Dim sSample As String
Dim i As Long
For i = 1 To 10
sSample = sSample & "Blah Blah" & i & vbNewLine
Next i
TextBox1.Text = sSample
'~~> Set to starting point
TextBox1.SelStart = 0
End Sub
答案 1 :(得分:1)
在UserForm的Initialize事件中,您可以使用textbox1.curline = 0
Private Sub UserForm_Initialize()
TextBox1.SetFocus ' to make next line work, first we must set focus on Textbox
TextBox1.CurLine = 0
End Sub