|
-
May 10th, 2006, 08:22 PM
#1
Thread Starter
Addicted Member
[RESOLVED] [02/03] Class variables for pathway
I am trying understand why my "path" variable will not work for File/OpenText etc yet my "f" & ''fn" variables work together. I have the following code in above the FormLoad window.
VB Code:
Dim fn As String 'Filename that is being manipulated
Dim f As String = ("C:\71151A2\")
Dim path As String = f & fn
If i use
VB Code:
fn = "PHONELISTS.TXT" 'File with phone directories
sr = File.OpenText(f & fn)
The code finds the file but if I use "path" in place of "f" & ''fn" it won't find it! Any clues as to why. I have declared the variable again in the sub procedure.
-
May 10th, 2006, 08:51 PM
#2
Re: [02/03] Class variables for pathway
Please do not create duplicate threads. They are a hindrance to the smooth running of the forum and they don't help you in any way.
After executing this code:
VB Code:
Dim fn As String 'Filename that is being manipulated
Dim f As String = ("C:\71151A2\")
Dim path As String = f & fn
the 'path' variable contains the string "C:\71151A2\". After that, setting 'fn' to something has no effect whatsoever on 'path', so after this code:
VB Code:
fn = "PHONELISTS.TXT" 'File with phone directories
'fn' contains the string "PHONELISTS.TXT" but 'path' still contains "C:\71151A2\". Had you used the debugger to check the value of path when you were using it you would have seen that.
-
May 10th, 2006, 09:45 PM
#3
Re: [02/03] Class variables for pathway
I am going to delete the dup
-
May 10th, 2006, 10:06 PM
#4
Thread Starter
Addicted Member
Re: [02/03] Class variables for pathway
 Originally Posted by jmcilhinney
Please do not create duplicate threads. They are a hindrance to the smooth running of the forum and they don't help you in any way.
Apologies for this I do not know how this happened. As for the debugger sometimes it works & sometimes it doesn't. I appear to have some minor gremlins that are inconsistent & intermitten with my system & produces unexpected & unusual results.
As to "path" explanation, I did see that but what I do not know is why!!!! ,because I Dim path = f & fn (which work by themselves).
Now I see!!!!! Thankyou
Rest assured I have appreciated your help very much to a newbie who knows enuff to be dangerous!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|