- 帖子
- 231
- 主題
- 55
- 精華
- 0
- 積分
- 293
- 點名
- 0
- 作業系統
- winxp
- 軟體版本
- office2003
- 閱讀權限
- 20
- 性別
- 男
- 來自
- KEELUNG
- 註冊時間
- 2010-7-24
- 最後登錄
- 2018-8-28
|
LISTBOX的COLUMNSWIDTH會出現錯誤訊息呢?
各位大大好:
小弟想學習LISTBOX的COLUMNSWIDTH
並直接引用OFFICE說明內的範例。
今執行該範例的COMMAND之後會出現如下的錯誤訊息。
小弟目前是使用OFFICE PROFESSIONAL 2010的版本。
語法如下:
Dim MyArray(2, 3) As String
Private Sub CommandButton1_Click()
'ColumnWidths requires a value for each column
'separated by semicolons
ListBox1.ColumnWidths = TextBox1.Text & ";" _
& TextBox2.Text & ";" & TextBox3.Text
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As _
MSForms.ReturnBoolean)
'ColumnWidths accepts points (no units), inches
'or centimeters; make inches the default
If Not (InStr(TextBox1.Text, "in") > 0 Or _
InStr(TextBox1.Text, "cm") > 0) Then
TextBox1.Text = TextBox1.Text & " in"
End If
End Sub
Private Sub TextBox2_Exit(ByVal Cancel As _
MSForms.ReturnBoolean)
'ColumnWidths accepts points (no units), inches
'or centimeters; make inches the default
If Not (InStr(TextBox2.Text, "in") > 0 Or _
InStr(TextBox2.Text, "cm") > 0) Then
TextBox2.Text = TextBox2.Text & " in"
End If
End Sub
Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
'ColumnWidths accepts points (no units), inches or
'centimeters; make inches the default
If Not (InStr(TextBox3.Text, "in") > 0 Or _
InStr(TextBox3.Text, "cm") > 0) Then
TextBox3.Text = TextBox3.Text & " in"
End If
End Sub
Private Sub UserForm_Initialize()
Dim i, j, Rows As Single
ListBox1.ColumnCount = 3
Rows = 2
For j = 0 To ListBox1.ColumnCount - 1
For i = 0 To Rows - 1
MyArray(i, j) = "Row " & i & ", Column " & j
Next i
Next j
'Load MyArray into ListBox1
ListBox1.List() = MyArray
'1-inch columns initially
TextBox1.Text = "1 in"
TextBox2.Text = "1 in"
TextBox3.Text = "1 in"
End Sub
謝謝各位大大。 |
-
-
TEST-AA.rar
(10.82 KB)
|