引用microsoft scripting runtime Option Explicit Dim fs As New FileSystemObjectPrivate Sub Command1_Click() If fs.FileExists("c:\test\a.bmp") Then fs.DeleteFile "c:\test\a.bmp" Else MsgBox "没有" End IfEnd Sub
If Dir("C:\WINDOWS\fdfd.ini") Then Kill "C:\WINDOWS\fdfd.ini" Else
End If
第二个问题 自己写一个函数返回真,则相同,否则不同 Function blnCompare() As Boolean Dim lngCnt&, lngCnt2 For lngCnt = 0 To Text1.Count - 1 For lngCnt2 = 0 To Text1.Count - 1 If lngCnt <> lngCnt2 Then If Text1(lngCnt) <> Text1(lngCnt2) Then blnCompare = False Exit Function End If End If Next Next blnCompare = True End FunctionPrivate Sub Command1_Click() If blnCompare Then MsgBox "相同" Else MsgBox "不同" End If End Sub
Option Explicit
Dim fs As New FileSystemObjectPrivate Sub Command1_Click()
If fs.FileExists("c:\test\a.bmp") Then
fs.DeleteFile "c:\test\a.bmp"
Else
MsgBox "没有"
End IfEnd Sub
我想写一个程序
作用如下
有一组控件数组textbox,判断它们的内容是否相同,相同警告斌执行相关程序
不同则执行下面的程序
Kill "C:\WINDOWS\fdfd.ini"
Else
End If
自己写一个函数返回真,则相同,否则不同
Function blnCompare() As Boolean
Dim lngCnt&, lngCnt2
For lngCnt = 0 To Text1.Count - 1
For lngCnt2 = 0 To Text1.Count - 1
If lngCnt <> lngCnt2 Then
If Text1(lngCnt) <> Text1(lngCnt2) Then
blnCompare = False
Exit Function
End If
End If
Next
Next
blnCompare = True
End FunctionPrivate Sub Command1_Click()
If blnCompare Then
MsgBox "相同"
Else
MsgBox "不同"
End If
End Sub