Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 12th, 2006, 10:32 AM
Princess Zea Princess Zea is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 97 Princess Zea User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 38 m 3 sec
Reputation Power: 4
File problem

Hi
I have this function that works fine on my local directory strDirectory = "c:\input" it gives me results e117.txt, e525, p42 etc but when I map it to strDirectory = "\\the-mapps-ht04\mysdata\ghai56\internal holding\Input Files2" it gives "\\the-mapps-ht04\mysdata\ghai56\internal holding\Input Files2" instead of just e117

this the function
Code:
 
Y =  Len(filename)- Len(strDirectory)+1
 
For i =y To Len(filename)
 
       x = Mid(filename, i, i + 1)
   'wscript.echo "Current x: " & x
              If Asc(x) >= 65 Then
                 position = i
                    Exit For
              End If
Next 
 findquestion = Right(filename, Len(filename) - (position) + 1)
end function


Thanks in advance

Reply With Quote
  #2  
Old December 12th, 2006, 03:44 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 57 m 26 sec
Reputation Power: 181
Where do you get the length of the filename and directory from? Look there for your problem.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old December 12th, 2006, 10:57 PM
Princess Zea Princess Zea is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 97 Princess Zea User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 38 m 3 sec
Reputation Power: 4
filename is the entire path and strdirectory contains part of the path excluding the acutal filename. I have a bunch of txt files

C0014E117.txt
C0016E117.txt
C0015E117.txt
C0018E117.txt
C0002E117.txt
C0003E117.txt

C0014j11.txt
C0015j11.txt
C0016j11.txt

C0014f11.txt
C0015f11.txt
C0016f11.txt

What I need to do is merge each bach of files with the same questions. So I am looking to do a function that checks for the first number before the letter so i get.
E117.txt
j11.txt
f11.txt


The above function does this on my local dir but when I map to the network I get a problem
Thanks

Reply With Quote
  #4  
Old December 13th, 2006, 12:33 AM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 57 m 26 sec
Reputation Power: 181
Since you can't (or won't) elaborate on what you mean by "I get a problem" all I can do is offer sympathy and encouragement in your debugging efforts.

Reply With Quote
  #5  
Old December 13th, 2006, 03:02 AM
Princess Zea Princess Zea is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 97 Princess Zea User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 38 m 3 sec
Reputation Power: 4
sorry,

Code:
Y =  Len(filename)- Len(strDirectory)+1
 
For i =y To Len(filename)
 
       x = Mid(filename, i, i + 1)
   'wscript.echo "Current x: " & x
              If Asc(x) >= 65 Then
                 position = i
                    Exit For
              End If
Next
 findquestion = Right(filename, Len(filename) - (position) + 1)
end function



I the function above works fine on my local dir

strDirectory = "c:\input\"

filename =c:\input\P0012E117.txt

when it goes through the function returns E117.txt if the txt file was H45000k45.txt it would return k45.txt


When I map to the network

strDirectory ="\\the-mapps-ht04\mysdata\ghai56\internal holding\Input Files2\"

filename="\\the-mapps-ht04\mysdata\ghai56\internal holding\Input Files2\P0012E117.txt"

gives

filename="\\the-mapps-ht04\mysdata\ghai56\internal holding\Input Files2\P0012E117.txt" instead of just
E117.txt

so the problem I am not sure why I get the wrong results when I map to the network using the same function.

Reply With Quote
  #6  
Old December 13th, 2006, 11:54 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 46th Plane (27500 - 27999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,932 Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 15th Grade (Above 100000 Reputation Level)  Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1Folding Points: 391471 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 12 h 17 m 53 sec
Reputation Power: 2002
your logic is flawed, only by chance you didn't discover it earlier.
it got nothing to do with network files, it would fail on any file name
long enough in specific format.
here is correct function, changes are highlighted in blue:
Code:
Function FindQuestion(filename, strDirectory)
	Dim Y, x, position
	Dim i
	Y =  Len(filename)- Len(strDirectory)
	position = 0
	For i=(Len(filename)-Y+2) To Len(filename)
		x = Mid(filename, i, i + 1)
		If Asc(x) >= 65 Then
			position = i
			Exit For
		End If
	Next
	FindQuestion = Right(filename, Len(filename) - (position) + 1)
End Function

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > File problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT