|
-
Oct 6th, 2008, 04:27 AM
#1
Thread Starter
PowerPoster
[RESOLVED] [2005] "String" issue
I've created a variable (sPath) to store the location of a file in a DB using the below. The issue is it's truncating part of the path.
The path should come out as:
'C:\M5\bin\Database\Financials\ZZZ.d'
but it is coming out as:
'C:\M5\bin\Database\Financials'
I have put a break point in and 'Symbol' and 'g_sDataMode' do have values.
Anyone know why the variable is not saving the full path?
Code:
Dim sPath As String
sPath = Application.StartupPath & "\Database\" & Sector & "\" & Symbol & "." & g_sDataMode
-
Oct 6th, 2008, 04:35 AM
#2
Re: [2005] "String" issue
This code in not enough. There is nothing special that can cause the problem. Can you please post the whole code block.
-
Oct 6th, 2008, 05:54 AM
#3
Thread Starter
PowerPoster
Re: [2005] "String" issue
Here is it
vb Code:
Public Function GetHistory(ByVal Symbol As String, _ ByVal Sector As String) As Boolean Dim sPath As String sPath = Application.StartupPath & "\Database\" & Sector & "\" & Symbol & "." & g_sDataMode Debug.Print(sPath) If System.IO.File.Exists(sPath) = False Then MsgBox("Could not locate data file for " & Symbol, MsgBoxStyle.Exclamation) Return False Exit Function End If Return True End Function
-
Oct 6th, 2008, 06:13 AM
#4
Junior Member
Re: [2005] "String" issue
Nothing seems to be wrong with the code. Put a breakpoint at the line:
sPath = ...
and check that all string variables do have a value. I bet you're dropping them somewhere...
Teme64 @ windevblog.blogspot.com
-
Oct 6th, 2008, 07:00 AM
#5
Re: [2005] "String" issue
Debug.WriteLine(Symbol)
Debug.WriteLine(g_sDataMode)
-
Oct 6th, 2008, 07:04 AM
#6
Lively Member
Re: [2005] "String" issue
Sometimes I have problems with filepaths also so now I convert my file path to shortpath before saving it and then converting back to longpath to be displayed to the user. I suppose it's not the best way, but it works for me.
-
Oct 6th, 2008, 07:49 AM
#7
Thread Starter
PowerPoster
Re: [2005] "String" issue
Don't know why but "Sector" had a large number of spaces added to the end of the value so 'Financials' was actually 'Financials '.
Once I removed the spaces everything is OK.
-
Oct 6th, 2008, 08:31 AM
#8
Re: [RESOLVED] [2005] "String" issue
so you ended up with something like this
sPath = Application.StartupPath & "\Database\" & Sector.Trim & "\" & Symbol.Trim & "." & g_sDataMode.Trim
-
Oct 6th, 2008, 09:10 AM
#9
Re: [RESOLVED] [2005] "String" issue
Some database systems, especially older ones, pad all their string data with spaces. We have an old Pervasive database app that does. It's painful having to add .Trim to the end of EVERYTHING... and it doesn't help it stores EVERYTHING as strings... even numbers and dates.
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
|