返回列表 上一主題 發帖

[發問] 有關 2010 ColumnWidths 發生錯誤

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)

TOP

謝謝大大。

如果依大大的方式
也就無法自行設定為
IN 或是 CM 了。
而HELP說明也有特別列出
其設定的方法,這又是如何
解釋呢?

設定 效果

90;72;90 第一行為 90 點 (1.25 英吋);第二行為 72 點 (1 英吋);第三行為 90 點。
6 cm;0;6 cm 第一行為 6 公分;第二行隱藏;第三行為 6 公分。
但第三行有一部分是看不到的,所以會有捲軸出現。
1.5 in;0;2.5 in 第一行為 1.5 英吋;第二行隱藏;第三行為 2.5 英吋。
2 in;;2 in 第一行為 2 英吋;第二行為 1 英吋 (預設);第三行為 2 英吋。
但第三行有一半是看不到的,所以會有捲軸出現。
(空白) 三行都一樣寬 (1.33 英吋)。

感恩大大!

TOP

版主大大你好:

   小弟是因將此附檔
移至公司最近購置office2010專業版
的電腦使用,卻發現二者不相容,
才感覺很困惑。而且office2010版之
說明也是可設定in or cm 呢?

感恩大大!

TOP

感恩版主大大。

近日常常向版主大大
請益,小弟真是受益良多。
實在很感激大大的相助。

感恩大大!

TOP

        靜思自在 : 脾氣嘴巴不好,心地再好也不能算是好人。
返回列表 上一主題