有三个控件分别是:
Drive1
Dir1
File1Private Sub GetSkinsPath() '获取'图片'文件路径,并把相对应的信息赋值给上面三个控件中。
Dim strTmp As String
strTmp="C:\xxa\skins\1.bmp"
If strTmp <> "" Then
Dim strFileName As String
Dim strPath As String
Dim strDir As String
'取得文件名
strFileName = Right(strTmp, InStr(1, StrReverse(strTmp), "\"))
'取路径
strPath = Mid(strTmp, InStr(1, strTmp, "\"), Len(strTmp))
strPath = Left(strPath, Len(strPath) - Len(strFileName))
'取驱动器名
strDir = Left(strTmp, InStr(1, strTmp, "\") - 1)
Drive1.Drive = strDir
Dir1.Path = strDir & strPath
File1.FileName = Dir1.Path'问题1
Else
Drive1.Drive = "C:\"
Dir1.Path = App.Path
File1.Path = Dir1.Path
End If
End Sub如何在File1控件显示Dir1.Path控件中的所有文件的同时,又能指定选中1.bmp文件(就如同用鼠标点击选中,该文件时出现'深蓝'色光条的样子)。
Drive1
Dir1
File1Private Sub GetSkinsPath() '获取'图片'文件路径,并把相对应的信息赋值给上面三个控件中。
Dim strTmp As String
strTmp="C:\xxa\skins\1.bmp"
If strTmp <> "" Then
Dim strFileName As String
Dim strPath As String
Dim strDir As String
'取得文件名
strFileName = Right(strTmp, InStr(1, StrReverse(strTmp), "\"))
'取路径
strPath = Mid(strTmp, InStr(1, strTmp, "\"), Len(strTmp))
strPath = Left(strPath, Len(strPath) - Len(strFileName))
'取驱动器名
strDir = Left(strTmp, InStr(1, strTmp, "\") - 1)
Drive1.Drive = strDir
Dir1.Path = strDir & strPath
File1.FileName = Dir1.Path'问题1
Else
Drive1.Drive = "C:\"
Dir1.Path = App.Path
File1.Path = Dir1.Path
End If
End Sub如何在File1控件显示Dir1.Path控件中的所有文件的同时,又能指定选中1.bmp文件(就如同用鼠标点击选中,该文件时出现'深蓝'色光条的样子)。
sendmessage()可以控制某一个窗体的对象.
For i = 0 To File1.ListCount
If File1.List(i) = "1.bmp" Then
File1.ListIndex = i
Exit For
End If
Next i