Results 1 to 9 of 9

Thread: [RESOLVED] [2005] "String" issue

  1. #1

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Resolved [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

  2. #2

  3. #3

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: [2005] "String" issue

    Here is it

    vb Code:
    1. Public Function GetHistory(ByVal Symbol As String, _
    2.                                     ByVal Sector As String) As Boolean
    3.  
    4.        
    5.         Dim sPath As String
    6.  
    7.         sPath = Application.StartupPath & "\Database\" & Sector & "\" & Symbol & "." & g_sDataMode
    8.  
    9.         Debug.Print(sPath)
    10.  
    11.         If System.IO.File.Exists(sPath) = False Then
    12.  
    13.             MsgBox("Could not locate data file for " & Symbol, MsgBoxStyle.Exclamation)
    14.  
    15.             Return False
    16.  
    17.             Exit Function
    18.         End If
    19.  
    20. Return True
    21.  
    22. End Function

  4. #4
    Junior Member
    Join Date
    Sep 2008
    Location
    Finland
    Posts
    20

    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

  5. #5
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: [2005] "String" issue

    Debug.WriteLine(Symbol)
    Debug.WriteLine(g_sDataMode)
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  6. #6
    Lively Member
    Join Date
    Jan 2007
    Posts
    96

    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.

  7. #7

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Resolved 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.

  8. #8
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: [RESOLVED] [2005] "String" issue

    so you ended up with something like this

    sPath = Application.StartupPath & "\Database\" & Sector.Trim & "\" & Symbol.Trim & "." & g_sDataMode.Trim
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  9. #9
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    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.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width