Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Why are my method Returns being truncated? [modified]

Why are my method Returns being truncated? [modified]

Scheduled Pinned Locked Moved Visual Basic
helpquestiondiscussion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TomGarth
    wrote on last edited by
    #1

    This was, as I suspected, just bad code, and that was recognized by another pair of eyes. The problem in finding it, is that at run time it is legitimate code, just not what I intended. The call to 'GetDefaultFileExtensions' should not have had an argument. tg '**************************************** I know that I get pretty dumb late in the day, so I hope someone can just point out the source my stupidity. Below is partial code from a class. I'm accessing the 2 properties and getting truncated results for both. For discussion's sake I'll just describe 1 of them - 'DefaultFileExtension'. This property's ReadOnly method calls the 'GetDefaultFileExtensions' function which should return the value of a constant, which in this case is "*.pdf". Look at the 2 'MsgBox' items in the code. I put them there for debugging. The message box inside of the 'GetDefaultFileExtensions' function displays "*.pdf". The message box in the 'DefaultFileExtension. property get displays "*" as the returned value from 'GetDefaultFileExtensions'. I've tried replacing the sReturn variable with the literal "*.pdf" and still get the same result. Also recompiled, and even rebooted. I'm stumped and open to suggestions. Thanks, Tom '****************************************** Friend Class clsFileDefinitionStructure Friend Enum fdFileType PDF_ft Image_ft End Enum Private Const mc_DefaultFiletypeDescription_PDF As String = "PDF files" Private Const mc_DefaultFiletypeDescription_Image As String = "Image files" Private Const mc_DefaultFileExtension_PDF As String = "*.pdf" Private Const mc_DefaultFileExtension_Image As String = "*.gif;*.bmp;*.jpg;*.jpeg;*.tif;*.png;*.pcd;*.pcx" Private m_FileType As fdFileType = fdFileType.PDF_ft Friend ReadOnly Property DefaultFileExtension() As String Get MsgBox(GetDefaultFileExtensions(m_FileType)) Return GetDefaultFileExtensions(m_FileType) End Get End Property Friend ReadOnly Property DefaultFileTypeDescription() As String Get Return GetDefaultFileTypeDescription(m_FileType) End Get End Property Private Function GetDefaultFileExtensions() As String Dim sReturn As String Select Case m_FileType Case fdFileType.Image_ft sReturn = mc_DefaultFileExtension_Image Case fdFileType.PDF_ft sReturn = mc_DefaultFileExtension_PDF Case Else sR

    D 1 Reply Last reply
    0
    • T TomGarth

      This was, as I suspected, just bad code, and that was recognized by another pair of eyes. The problem in finding it, is that at run time it is legitimate code, just not what I intended. The call to 'GetDefaultFileExtensions' should not have had an argument. tg '**************************************** I know that I get pretty dumb late in the day, so I hope someone can just point out the source my stupidity. Below is partial code from a class. I'm accessing the 2 properties and getting truncated results for both. For discussion's sake I'll just describe 1 of them - 'DefaultFileExtension'. This property's ReadOnly method calls the 'GetDefaultFileExtensions' function which should return the value of a constant, which in this case is "*.pdf". Look at the 2 'MsgBox' items in the code. I put them there for debugging. The message box inside of the 'GetDefaultFileExtensions' function displays "*.pdf". The message box in the 'DefaultFileExtension. property get displays "*" as the returned value from 'GetDefaultFileExtensions'. I've tried replacing the sReturn variable with the literal "*.pdf" and still get the same result. Also recompiled, and even rebooted. I'm stumped and open to suggestions. Thanks, Tom '****************************************** Friend Class clsFileDefinitionStructure Friend Enum fdFileType PDF_ft Image_ft End Enum Private Const mc_DefaultFiletypeDescription_PDF As String = "PDF files" Private Const mc_DefaultFiletypeDescription_Image As String = "Image files" Private Const mc_DefaultFileExtension_PDF As String = "*.pdf" Private Const mc_DefaultFileExtension_Image As String = "*.gif;*.bmp;*.jpg;*.jpeg;*.tif;*.png;*.pcd;*.pcx" Private m_FileType As fdFileType = fdFileType.PDF_ft Friend ReadOnly Property DefaultFileExtension() As String Get MsgBox(GetDefaultFileExtensions(m_FileType)) Return GetDefaultFileExtensions(m_FileType) End Get End Property Friend ReadOnly Property DefaultFileTypeDescription() As String Get Return GetDefaultFileTypeDescription(m_FileType) End Get End Property Private Function GetDefaultFileExtensions() As String Dim sReturn As String Select Case m_FileType Case fdFileType.Image_ft sReturn = mc_DefaultFileExtension_Image Case fdFileType.PDF_ft sReturn = mc_DefaultFileExtension_PDF Case Else sR

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      I have no idea why this is happening. The code doesn't show anything that would cause it. I'd remove the MsgBox lines and just step through the code, line-by-line, using the debugger and watch the variables involved.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      T 1 Reply Last reply
      0
      • D Dave Kreskowiak

        I have no idea why this is happening. The code doesn't show anything that would cause it. I'd remove the MsgBox lines and just step through the code, line-by-line, using the debugger and watch the variables involved.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        T Offline
        T Offline
        TomGarth
        wrote on last edited by
        #3

        Hi Dave, I had already used the debugger while working line by line. I added the message boxes to make it easier to try different variations. The only thing the code shows is that I stupidly added the FileType Enum as an argument to a call that didn't ask for an argument. The result was explained to me by in a very elegant answer from Armin Zingler at: http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.dotnet.languages.vb&mid=03cf9ea6-b81a-48fe-ad43-f1f48517dbdc[^] I've copied his explanation here: ************************************************************ This is awesome... The thing is that GetDefaultFileExtensions(m_FileType) is short for GetDefaultFileExtensions.Chars(m_FileType) because Chars is the default property of a String, and because GetDefaultFileExtensions does /not/ have arguments. As m_FileType is 0, this is actually GetDefaultFileExtensions.Chars(0) So, you get the first char of the string, which is "*" only. Armin ************************************************************ Cool huh?

        Tom Garth Developer R. L. Nelson and Associates, Inc., Virginia

        D 1 Reply Last reply
        0
        • T TomGarth

          Hi Dave, I had already used the debugger while working line by line. I added the message boxes to make it easier to try different variations. The only thing the code shows is that I stupidly added the FileType Enum as an argument to a call that didn't ask for an argument. The result was explained to me by in a very elegant answer from Armin Zingler at: http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.dotnet.languages.vb&mid=03cf9ea6-b81a-48fe-ad43-f1f48517dbdc[^] I've copied his explanation here: ************************************************************ This is awesome... The thing is that GetDefaultFileExtensions(m_FileType) is short for GetDefaultFileExtensions.Chars(m_FileType) because Chars is the default property of a String, and because GetDefaultFileExtensions does /not/ have arguments. As m_FileType is 0, this is actually GetDefaultFileExtensions.Chars(0) So, you get the first char of the string, which is "*" only. Armin ************************************************************ Cool huh?

          Tom Garth Developer R. L. Nelson and Associates, Inc., Virginia

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Oh my God! I was poking through that code for an hour and didn't see it! :->

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups