If Dir("c:\winnt", vbDirectory) <> "" Then
MsgBox "存在"
Else
MsgBox "不存在"
End If
MsgBox "存在"
Else
MsgBox "不存在"
End If
解决方案 »
- 有函数能够知道 class 名称吗
- 谁给个调用CAD的代码?
- 这个程序该怎么写
- 用代码设置ACCESS2000数据库表的属性?
- 图片存入Access问题。
- 请高手看我的关于文件方面的一个问题?请各位兄弟帮助!在线等待!分不够可再加!!
- 在哪里能买到正版的ActiveReport软件?
- 求: 把一个字符串里面的所有全角字符变成半角字符的函数
- 求教各位大虾,如何做一个对话框资源编辑器那样的效果?
- 我在http://jszb.jsagri.gov.cn/vb/default.htm中看到一个需要的程序,点旁边的“DOWNLOAD”,可是它“不理”我,我真的很需要这几个程序,怎么办?
- 请问在VB中,用crystal Report 7.0,横排打印怎么设定?
- 在线等待,请大家帮帮忙,问msflexgrid控件中能加如其他控件吗
'引用Microsoft Scripting Runtime
Option Explicit
Dim fsoSys As New Scripting.FileSystemObject
Dim fsoFile As FilePrivate Sub Command1_Click()
Dim temp As String
Dim CreateDate As Variant
If Not fsoSys.FileExists("c:\netlog.txt") Then
MsgBox "文件不存在"
Else
Set fsoFile = fsoSys.GetFile("c:\netlog.txt")
temp = "文件名:" & fsoFile.Name & vbCrLf
temp = temp & "文件类型:" & fsoFile.Type & vbCrLf
temp = temp & "文件大小:" & CStr(fsoFile.Size) & "字节" & vbCrLf
'因为在win98下无法测试创建时间,代码应该类似下面
'CreateDate = fsoFile.DateCreated
'temp = temp & "创建时间:" & CDate(CreateDate) & vbcrlf
temp = temp & "修改时间:" & fsoFile.DateLastModified
RichTextBox1.Text = temp
End If
End Sub
如何获得一个BYTE数组的大小。也就是类似len(aaa)一样的功能。
' FUNCTION: FileExists
' Determines whether the specified file exists
'
' IN: [strPathName] - file to check for
'
' Returns: True if file exists, False otherwise
'-----------------------------------------------------------
'
Function FileExists(ByVal strPathName As String) As Integer
Dim intFileNum As Integer On Error Resume Next '
' If the string is quoted, remove the quotes.
'
strPathName = strUnQuoteString(strPathName)
'
'Remove any trailing directory separator character
'
If Right$(strPathName, 1) = gstrSEP_DIR Then
strPathName = Left$(strPathName, Len(strPathName) - 1)
End If '
'Attempt to open the file, return value of this function is False
'if an error occurs on open, True otherwise
'
intFileNum = FreeFile
Open strPathName For Input As intFileNum FileExists = IIf(Err = 0, True, False) Close intFileNum Err = 0
End Function