vb if语句

来源:百度知道 编辑:UC知道 时间:2024/05/15 23:22:18
Private Sub Form_Load()
Dim strAppPath As String
Dim strAppPath1 As String
strAppPath = App.Path
If starappphth1 = App.Path = "e:\" Then

If Right(strAppPath, 1) <> "\" Then strAppPath = strAppPath + "\"
FileCopy strAppPath + App.EXEName + ".EXE", "e:\" & App.EXEName + ".EXE"
End If
End Sub

程序本身复制到E盘下
怎样才能实现 如果发现自身路径已经在E盘则不复制

'在运行前,要确保已经编译了,因为程序中用的是本文件,则要先生成可执行文件便于执行

Private Sub Command1_Click()

Dim strPath As String

strPath = App.Path '获取当前路径

If Right(strPath, 1) <> "\" Then '判断最后一个字符是否是“\”
strPath = strPath + "\"
End If

If Dir("e:\" + App.EXEName + ".exe") = "" Then
FileCopy strPath + App.EXEName + ".exe", "E:\" & App.EXEName + ".exe"
'Dir()函数返回空表示文件不存在,若存在返回文件的路径
End If

End Sub
回答完毕,还有问题请和我联系,QQ群:30538950

使用FileSystemObject应该可以实现。。我用的也很少!
提议一下!