注册 登录
编程论坛 VB6论坛

求助 If Dir(App.Path & "\" & text1.text, vbDirectory) = "&q

tieguanyin 发布于 2019-01-08 13:03, 1804 次点击
If Dir(App.Path & "\" & text1.text, vbDirectory) = "" Then
Label7.Caption = "不存在"
' 生成

Else
Label7.Caption = "已存在"
’创建生成
End If

text1.text 显示的事 当前时间  20190555 我吧这个当做目录名 创建
现在判断的时候 IF老出错  我的写法哪里不对 ????

If Dir(App.Path & "\" & text1.text, vbDirectory) = "" Then
2 回复
#2
ictest2019-01-08 14:37
程序代码:
Private Sub Command1_Click()
If Dir(App.Path & "\" & Text1.Text, vbDirectory) = "" Then
Label1.Caption = "不存在,准备生成 " & Format(Date, "yyyymmdd") & " 目录"
MkDir App.Path & "\" & Text1.Text
Else
Label1.Caption = "已存在 " & Format(Date, "yyyymmdd") & " 目录,不再生成"
End If
End Sub

Private Sub Form_Load()
Text1.Text = Format(Date, "yyyymmdd")
Label1.Caption = ""
End Sub



一般我就写一句就完了,没有就直接生成,有就不生成,不高兴加提示。

程序代码:
Private Sub Command1_Click()
If Dir(App.Path & "\" & Text1.Text, vbDirectory) = "" Then MkDir (App.Path & "\" & Text1.Text)
End Sub

Private Sub Form_Load()
Text1.Text = Format(Date, "yyyymmdd")
End Sub
#3
wds12019-01-08 14:48
出错可能是text1.text没有赋值。
1