【发布时间】:2017-02-08 04:41:51
【问题描述】:
对于如何实现文本框的代码,我有点困惑。我正在尝试设置一个显示文本框的表单,用户可以选择输入值(参数),然后将其输入另一个子程序并运行该子程序。例如,在以下代码中:
Option Explicit
Sub FillSampleTable()
'This will fill an x by y grid of numbers incrementing to use for testing purposes
Dim x As Double
Dim y As Double
Dim z As Double
Dim OffsetColumn As Integer
Dim offsetrows As Integer
Dim a As Long
Application.ScreenUpdating = False
a = 10
OffsetColumn = 1
offsetrows = 1
z = 0
For x = 1 To a
For y = 1 To a
z = z + 1
Cells(x + offsetrows, y + OffsetColumn).Select
Cells(x + offsetrows, y + OffsetColumn).Value = z
Next y
Next x
Application.ScreenUpdating = True
End Sub
我希望有一个文本框来提示用户输入“a”的值,并且一旦加载了该值,就会运行这个子程序。如果没有输入任何值,那么它会发出错误消息框并返回到输入屏幕。 当我单击该框时,我得到:
Private Sub GridSize_Change()
'I renamed text box GridSize
End Sub
但不知道该怎么办。 MS Excel v 2016。
【问题讨论】: