473,785 Members | 2,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

opening a file that exists, but says it doesn't

Hi there,
I am a newbie working from the Visual Basic Programmers Workbook. I have
created a text file called Origin.txt but when I go to open it I keep
getting a "file does not exist" error, although it definitely does.
Any ideas?

Here is code:

Private Sub cmdInputFile_Cl ick()
Dim intYear As Integer
Dim intNSWScore As Integer
Dim intQLDScore As Integer

Me.Cls
'Use Dir to verify that the file exists:
If Dir("C:\Documen ts and Settings\Owner\ My
Documents\VBWor k\Expressions\O rigin.txt") = "" Then
MsgBox "File not found"
'Take a premature exit:
Exit Sub
End If
Open "C:\Documen ts and Settings\Owner\ My
Documents\VBWor k\Expressions\O rigin.txt" For Input As #1
Print "Year", "NSW", "QLD"
Do While Not EOF(1)
Input #1, intYear, intNSWScore, intQLDScore
'Print to the form:
Print intYear, intNSWScore, intQLDScore
Loop
Close #1
End Sub
Jul 17 '05 #1
1 2754
I tried it and it worked fine. I suspect the file you are looking for may
exist in a location other than the one you are expecting to find it. Place
the Origin.txt file in the same location as your application and adapt your
code to look for it there using App.Path.

"V Bradley" <vo*******@yaho o.com> wrote in message
news:20******** *************@n ews02.tsnz.net. ..
Hi there,
I am a newbie working from the Visual Basic Programmers Workbook. I have
created a text file called Origin.txt but when I go to open it I keep
getting a "file does not exist" error, although it definitely does.
Any ideas?

Here is code:

Private Sub cmdInputFile_Cl ick()
Dim intYear As Integer
Dim intNSWScore As Integer
Dim intQLDScore As Integer

Me.Cls
'Use Dir to verify that the file exists:
If Dir("C:\Documen ts and Settings\Owner\ My
Documents\VBWor k\Expressions\O rigin.txt") = "" Then
MsgBox "File not found"
'Take a premature exit:
Exit Sub
End If
Open "C:\Documen ts and Settings\Owner\ My
Documents\VBWor k\Expressions\O rigin.txt" For Input As #1
Print "Year", "NSW", "QLD"
Do While Not EOF(1)
Input #1, intYear, intNSWScore, intQLDScore
'Print to the form:
Print intYear, intNSWScore, intQLDScore
Loop
Close #1
End Sub

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3793
by: Display Name | last post by:
the customer I'm developing a site for uses a canned form-parsing page that allows her to have an email subscription opt-in page add emails to a list she can manage using a link that you point your HTML form to. the actual form-parsing page resides on a server that's uneditable to me since it sits on an inaccessible server. my problem is more irritating than anything; everything double-submits.. when you submit the form, I've forced a...
2
9390
by: Zeno Lee | last post by:
I'm using File.Exists to test a file on my C: drive. My program was strongly named and had caspol -af run on it to allow it to run from the network. There are 3 ways I am doing this: 1) Run from my C: drive, File.Exists works properly and says C:\Temp\test.txt exists 2) Run from my H:\ (network) drive, File.Exists says the file doesn't exist. 3) Run from Visual Studio debugger, with project configuration property
6
13731
by: Chad Crowder | last post by:
Getting the following error on my production server whether the file exists or not: "System.IO.IOException: Cannot create a file when that file already exists." Here's the code generating the error (seems to be happening when I try creating a directory) If dirmgr.Exists("s:\blah\" & txt_name.Text) Then lblerror.Text = lblerror.Text & "Unable to build physical path. " &
17
8029
by: Peter Duniho | last post by:
I searched using Google, on the web and in the newsgroups, and found nothing on this topic. Hopefully that means I just don't understand what I'm supposed to be doing here. :) The problem: I am trying to use the SaveFileDialog class to get a filename, which is subsequently opened for writing (write access, read sharing, but using read/write sharing doesn't make the problem go away anyway). Sometimes, on the statement where I...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10330
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10153
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.