高手请赐教!
Private Sub TvwTK_Click()<BR>Additems<BR>End SubPrivate Sub UserForm_Initialize()<BR>Ini_userform
End Sub<BR>Sub Ini_userform()
SysPath = ThisDrawing.GetVariable("users5")
IniTvwtk
With Me<BR> .Image1.SpecialEffect = fmSpecialEffectRaised<BR> .Image2.SpecialEffect = fmSpecialEffectRaised<BR> .Image3.SpecialEffect = fmSpecialEffectRaised<BR> .Image4.SpecialEffect = fmSpecialEffectRaised<BR> .Image5.SpecialEffect = fmSpecialEffectRaised<BR> .Image6.SpecialEffect = fmSpecialEffectRaised<BR> .Image7.SpecialEffect = fmSpecialEffectRaised<BR> .Image8.SpecialEffect = fmSpecialEffectRaised<BR> .Image9.SpecialEffect = fmSpecialEffectRaised<BR> .Image10.SpecialEffect = fmSpecialEffectRaised<BR> .Image11.SpecialEffect = fmSpecialEffectRaised<BR> .Image12.SpecialEffect = fmSpecialEffectRaised<BR>End With<BR> <BR> <BR>End Sub
Sub IniTvwtk()<BR>On Error GoTo ErrHandler<BR>Dim MyName, path_W<BR>Dim S, F As Nodes<BR>Dim i
i = 0<BR>SysPath = ThisDrawing.GetVariable("users5")
path_W = SysPath + "lib\"
Me.TvwTK.LineStyle = tvwTreeLines<BR>Me.TvwTK.HideSelection = False
Me.TvwTK.BorderStyle = ccNone<BR>On Error Resume Next
Me.TvwTK.LineStyle = tvwRootLines<BR>F.Image = "library"<BR>F.Expanded = True
MyName = Dir(path_W, vbDirectory)<BR>Do While MyName <> ""<BR> If MyName <> "." And MyName <> ".." Then<BR> If (GetAttr(path_W & MyName) And vbDirectory) = vbDirectory Then<BR> i = i + 1<BR> Set F = Me.TvwTK.Nodes.Add(, , "F" & i, Trim(MyName))<BR> End If<BR> End If<BR>MyName = Dir<BR>Loop
ErrHandler:<BR> Exit Sub<BR>End Sub
Sub Additems()<BR> Dim nodeDwgName As Node<BR> Dim tmpstr As String<BR> Dim strKey As String<BR> Dim strKey1 As String<BR> Dim strParent As String<BR> Dim tmp_FileName As String<BR> Dim File_List<BR> Dim tmpNode As Node<BR> Dim tmpKey As String<BR> Dim ww<BR> <BR> Dim Path_Lib As String<BR> Dim i As Integer<BR> Dim j As Integer<BR> <BR> SysPath = ThisDrawing.GetVariable("users5")
Path_Lib = SysPath + "lib\"
If TvwTK.SelectedItem.Children = 0 Then<BR> strKey = Trim(TvwTK.SelectedItem.Key)<BR> tmpstr = Trim(TvwTK.SelectedItem.Text)<BR> strKey1 = Left(strKey, 1)<BR> Select Case strKey1<BR> Case "F"<BR> File_List = W_GetFileListByPath(Path_Lib + tmpstr + "\", "")<BR> For i = LBound(File_List) To UBound(File_List)<BR> tmp_FileName = Left(File_List(i), Len(File_List(i)) - 4)<BR> Set nodeDwgName = TvwTK.Nodes.Add(strKey, tvwChild, "S" & strKey & i, tmp_FileName)<BR> <BR> ww = ss(i, Path_Lib + tmpstr + "\" + File_List(i))<BR> <BR> Next i<BR> 'Me.Label1.Caption = Trim(TvwTK.SelectedItem.Text)<BR> Case "S"<BR> <BR> StrFileName = Trim(TvwTK.SelectedItem.Text)<BR> tmpKey = Right(Trim(TvwTK.SelectedItem.Key), 1)<BR>' j = Val(tmpKey) + 1<BR>' If j / 12 <= 1 Then<BR>' ss = "Me.Image" & j & ".Picture =" & ""<BR>' TvwTK<BR>' ElseIf j / 12 <= 2 Then<BR>' ElseIf j / 12 <= 3 Then<BR>' ElseIf j / 12 <= 4 Then<BR>' End If<BR> <BR> Set tmpNode = TvwTK.SelectedItem.Parent<BR> strParent = tmpNode.Text<BR> <BR> StrFilePath = Path_Lib & strParent & "\" & Trim(TvwTK.SelectedItem.Text)<BR> 'Me.Label1.Caption = StrFileName
End Select<BR> <BR> End If<BR>End Sub<BR> <BR>Function ss(i As Integer, FileName As String) As Variant<BR>ss = "me.Image" & i + 1 & ".picture=" & FileName & vbCr<BR>End Function
程序中我不想一个一个的写语句将image的picture付值,我想通过函数ss这样的形式实现,当然了我写的ss函数是不能实现的,不知道有没有办法实现?请高手赐教! set me.Controls("Image" & i+1).picture=loadpicture(filename) 谢谢!飞狐兄!
页:
[1]