|
liwen 发表于 2009-9-8 23:03
版主大人,你是不是通过下面这些语句实现列表框中,选中的记录能自动保存,且求和值显示在文本框中也能保存的功能?(即下次显示窗体时仍能看到上次选中的记录和求和值)
如果是的话,还有劳请版主大人分析给我听听,尤其是结尾那段!
大恩不言谢!!!
Private Sub CommandButton1_Click()
For i = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(i) Then
A = A & "," & i
End If
Next
'Worksheets("1").Range(rc) = Mid(A, 2)
Sheets(1).Cells(2, ra) = Mid(A, 2)
Range(rb) = Me.TextBox1
Unload Me
End Sub
--------------------------------------------
Dim B As Variant
B = Split(Sheets(1).Cells(2, ra), ",")
----------------------------------------------
Private Sub UserForm_Initialize()
Dim B As Variant
B = Split(Sheets(1).Cells(2, ra), ",")
Me.TextBox1 = 0
For i = 0 To UBound(B)
Me.ListBox1.ListIndex = B(i)
Me.ListBox1.Selected(B(i)) = True
Next
End Sub |
|