主题:为什么运行时组合框和文件列表框不能同步?
我的代码和界面如下:
Dim choicedfile As String
Private Sub cmdcopy_Click()
Dim sourfile As String
Dim destfile As String
str2$ = "请输入复制目的文件"
sourfile = choicedfile
destfile = InputBox$(str2$, "复制文件")
If destfile <> "" Then
FileCopy sourfile, destfile
End If
End Sub
Private Sub cmdkill_Click()
Dim killedfile As String
killedfile = choicedfile
Title$ = "数据检查框"
msg1$ = "你要删除文件:" & killedfile
x = MsgBox(msg1$, 35, Title$)
If x = 6 Then
Kill killedfile
End If
End Sub
Private Sub cmdrename_Click()
Dim oldname As String
Dim newname As String
Title$ = "重新命名"
str0$ = "请再输入一遍需要修改的文件名(全路径)"
str1$ = choicedfile + Chr$(10) + Chr$(13) + str0$
str2$ = "请输入新文件名"
oldname = InputBox$(str1$, Title$)
msg$ = "确认被更改的文件名" & oldname
p = MsgBox(msg$, 35, "数据检查框")
If p = 6 Then
newname = InputBox(str2$, Title$)
Name oldname As newname
MsgBox "你的新文件名是:" + newname
End If
End Sub
Private Sub Combo1_Change()
Filelist.Pattern = Combo1.Text '将在组合框中选择的文件类型放在列表框的pattern属性中
End Sub
Private Sub Dirlist_Change()
Filelist.Path = Dirlist.Path
Label8.Caption = Dirlist.Path
End Sub
Private Sub Drivelist_Change()
Dirlist.Path = Drivelist.Drive
End Sub
Private Sub Filelist_Click()
Label4.Caption = Filelist.FileName '当前被选择的文件名赋给标签4
If Right$(Dirlist.Path, 1) = "\" Then
choicedfile = Dirlist.Path + Filelist.FileName '将被选定的文件的名字保存在变量choicedfile中
Else
choicedfile = Dirlist.Path + "\" + Filelist.FileName '将被选定的文件的名字保存在变量choicedfile中
End If
End Sub
Private Sub Form_Load()
Label8.Caption = Dirlist.Path
End Sub
Dim choicedfile As String
Private Sub cmdcopy_Click()
Dim sourfile As String
Dim destfile As String
str2$ = "请输入复制目的文件"
sourfile = choicedfile
destfile = InputBox$(str2$, "复制文件")
If destfile <> "" Then
FileCopy sourfile, destfile
End If
End Sub
Private Sub cmdkill_Click()
Dim killedfile As String
killedfile = choicedfile
Title$ = "数据检查框"
msg1$ = "你要删除文件:" & killedfile
x = MsgBox(msg1$, 35, Title$)
If x = 6 Then
Kill killedfile
End If
End Sub
Private Sub cmdrename_Click()
Dim oldname As String
Dim newname As String
Title$ = "重新命名"
str0$ = "请再输入一遍需要修改的文件名(全路径)"
str1$ = choicedfile + Chr$(10) + Chr$(13) + str0$
str2$ = "请输入新文件名"
oldname = InputBox$(str1$, Title$)
msg$ = "确认被更改的文件名" & oldname
p = MsgBox(msg$, 35, "数据检查框")
If p = 6 Then
newname = InputBox(str2$, Title$)
Name oldname As newname
MsgBox "你的新文件名是:" + newname
End If
End Sub
Private Sub Combo1_Change()
Filelist.Pattern = Combo1.Text '将在组合框中选择的文件类型放在列表框的pattern属性中
End Sub
Private Sub Dirlist_Change()
Filelist.Path = Dirlist.Path
Label8.Caption = Dirlist.Path
End Sub
Private Sub Drivelist_Change()
Dirlist.Path = Drivelist.Drive
End Sub
Private Sub Filelist_Click()
Label4.Caption = Filelist.FileName '当前被选择的文件名赋给标签4
If Right$(Dirlist.Path, 1) = "\" Then
choicedfile = Dirlist.Path + Filelist.FileName '将被选定的文件的名字保存在变量choicedfile中
Else
choicedfile = Dirlist.Path + "\" + Filelist.FileName '将被选定的文件的名字保存在变量choicedfile中
End If
End Sub
Private Sub Form_Load()
Label8.Caption = Dirlist.Path
End Sub