Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open is not declared error

Status
Not open for further replies.

manguilla

Programmer
Jul 20, 2004
52
US
Hello again everyone. I am writing a vb .exe app in .NET 2003 and I am having a problem with an error. The error says, "'Open is not declared. File I/O functionality is available in the 'Microsoft.VisualBasic' namespace." I think that I need add a reference to the System.IO object but I cannot find it listed un the .NET tab in the Add Reference window. Is this my problem or is it something else???? Here is my code. I am just using 1 module and the program is for moving files and seeing if a file is already opened. Thanks again everyone in advance.

Manguilla


Module Module1

Sub Main()
Dim strDir As String
Dim strSource As String
Dim strNew As String
Dim strDest As String
Dim strFile As String
Dim I As Integer
Dim currFile As String
Dim compFile As String
Dim txt As String
Dim strNum As String
Dim currNum As String
Dim finNum As Integer
Dim N As Integer
Dim pos As Integer

strDir = "C:\Win2000\"
strDest = "C:\Captures\"
txt = "Capture"

currFile = Dir(strDest & "*.*")
If currFile <> "" Then
Do While currFile <> ""
strNum = Mid$(currFile, 1, 2)
currNum = Int(strNum)
If finNum < currNum Then
finNum = currNum
End If
currFile = Dir()
Loop
End If

If finNum = 0 Then
finNum = 10
Else
finNum = finNum + 1
End If

strFile = Dir(strDir & "*.*")

Do While strFile <> ""
pos = InStr(strFile, txt)
If pos > 0 Then
I = I + 1
strSource = strDir & strFile
strNew = strDest & finNum & "capture_" & I & ".log"
If Not IsFileLocked(strSource) Then
FileCopy(strSource, strNew)
System.IO.File.Delete(strSource)
strSource = strNew
End If
End If
strFile = Dir()
Loop

End Sub

Private Function IsFileLocked(ByVal filePath As String) As Boolean
On Error Resume Next

If Dir(filePath) <> "" Then
Dim fileHandle As Integer
fileHandle = FreeFile()
Open filePath For Input Lock Read As #fileHandle
If Err.Number = 0 Then
Close #fileHandle
IsFileLocked = False
ElseIf Err.Number = 70 Then
IsFileLocked = True
End If
Else
IsFileLocked = False
End If

End Function

End Module

 
Is this VB6 or VB.NET? If .NET then read faq222-2244 and repost in forum796 - this is the VB6 forum

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
I am writing this in VB6 but I am using Visual Studio .NET 2003. Thanks.

Manguilla
 
... and I think strongm's "Er ..." means that, if it's Visual Studio .NET 2003, then it's VB[red].NET[/red] and not VB[red]6[/red]

Check out forum796.
 
Oh I'm sorry. I though you could create a VB6 app in VS .NET 2003. I'll post it there. Thanks.

Manguilla
 
Heh - see, I can now communicate whole copncepts using just two letters and three dots.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top