克服VBAinput框字符限制
我用来收集文本InputBox的当前函数显然不能接受超过255个字符,而且我需要能够收集更多的东西吗? 有一个参数或不同的function,我可以用来增加这个限制?
要迂回,input框会让你input255个字符,但它只会返回254个字符。
除此之外,是的,你需要创build一个带有文本框的简单表单。 然后只要做一点“辅助function”就好:
Function getBigInput(prompt As String) As String frmBigInputBox.Caption = prompt frmBigInputBox.Show getBigInput = frmBigInputBox.txtStuff.Text End Function
或类似的东西…
感谢BradC的信息。 我的最终代码大致如下,我有一个button,调用我创build的窗体,并定位一下,因为我在第一次使用后每次都遇到了窗体出现错误的地方。
Sub InsertNotesAttempt() NoteEntryForm.Show With NoteEntryForm .Top = 125 .Left = 125 End With End Sub
用户窗体是一个TextBox和两个CommandButton(Cancel和Ok)。 button的代码如下所示:
Private Sub CancelButton_Click() Unload NoteEntryForm End Sub Private Sub OkButton_Click() Dim UserNotes As String UserNotes = NotesInput.Text Application.ScreenUpdating = False If UserNotes = "" Then NoteEntryForm.Hide Exit Sub End If Worksheets("Notes").ListObjects("Notes").ListRows.Add (1) Worksheets("Notes").Range("Notes").Cells(1, 1) = Date Worksheets("Notes").Range("Notes").Cells(1, 2) = UserNotes Worksheets("Notes").Range("Notes").Cells(1, 2).WrapText = True ' Crap fix to get the wrap to work. I noticed that after I inserted another row the previous rows ' word wrap property would kick in. So I just add in and delete a row to force that behaviour. Worksheets("Notes").ListObjects("Notes").ListRows.Add (1) Worksheets("Notes").Range("Notes").Item(1).Delete NotesInput.Text = vbNullString NotesInput.SetFocus ' Retains focus on text entry box instead of command button. NoteEntryForm.Hide Application.ScreenUpdating = True End Sub
我没有足够的代表评论,但在帮助器的子form_load中,您可以添加:
me.AutoCenter = True
除此之外,你可以这样做:
NoteEntryForm.Show Forms("NoteEntryForm").AutoCenter = True
当我从我的两台额外的显示器上class时,我的访问表单变得困惑,我的一台额外的显示器在家里,有时会丢在angular落里。 这AutoCenter已经成为我的每一个表格的forms属性。