Private Sub Command2_Click()Dim fs As New FileSystemObject
s = 0
Folder1 = "d:\考生文件夹"
'1
If fs.FileExists(Folder1 & "\abc.txt") Then
num = "√"
s = s + 20
Else
num = "×"
End If
这一部分是说如果在考生文件夹下有指定的文件,分数就加20,同时给出提示是对还是错,我有很多这样的部分,但是所有结果显示全部都是×,可能我用错了,帮我看看好吗

解决方案 »

  1.   


    s = 0
    Folder1 = "d:\考生文件夹"
    '1
    If dir(Folder1 & "\abc.txt")<>"" Then
    num = "√"
    s = s + 20
    Else
    num = "×"
    End If
      

  2.   

    在水之舟:程序条件就是对这个文件夹的存在进行判断,其他就没什么了,我想问在用s和num的时候前面需要什么定义吗?具体我也写了,但是结果就是不行,你能不能帮我写写看这个定义啊?
      

  3.   

    Dim fs As New FileSystemObject
    文件对象是这样用的吗?
      

  4.   

    把 & "\abc.txt"去掉
    Private Sub Command2_Click()Dim fs As New FileSystemObjects = 0
    Folder1 = "d:\考生文件夹"
    '1
    If fs.FileExists(Folder1 ) Then
    num = "√"
    s = s + 20
    Else
    num = "×"
    End If
      

  5.   

    老兄给你一点提示,不知道你的全部程序!
        你的判断语句,有毛病呀!  
         if fs.FileExists(Folder1 & "\abc.txt") then
       没有判断条件呀!
       给出一个条件他才知道对错呀!
      

  6.   

    {{{Dim fs As New FileSystemObject
    文件对象是这样用的吗?}}}}用过的啊,算出的结果值S是正确的,就是这个num出来都是错的,我真的没办法了,
     
      

  7.   

    Private Sub Command2_Click()
    dim filepath,filename as string
    filepath="d:\考生文件夹\"
    filename="abc.txt"
    s = 0
    If dir(filepath+filename,vbNormal)<>"" Then
    num = "√"
    s = s + 20
    Else
    num = "×"
    End If
      

  8.   

    谢谢大家的帮忙了,你们都误会了.我的程序结构上是没有问题的,就是对NUM的引用上可能有点问题的,但是我是菜的,我不知道,大家帮忙啊!
      

  9.   

    '改成这样试试
    Private Sub Command2_Click()Dim fs As New FileSystemObject
    s = 0
    Folder1 = "d:\考生文件夹"
    '1
    If dir(Folder1 & "\abc.txt")<>"" Then
    num = "√"
    s = s + 20
    Else
    num = "×"
    End If