Announcement

Collapse
No announcement yet.

Can't compile a VB program because of $Left

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can't compile a VB program because of $Left

    I have to throw this one out to the VB6 peeps out there. In my app, I'm using a function to detect the current Windows version that's running on the machine the app is installed on. I didn't design the function, but it IS freeware, for those who might be sticklers about such things.

    My problem resides in the following code, with the offending statement in red:
    =======================

    Public Declare Function GetVersionEx Lib "kernel32" _
    Alias "GetVersionExA" _
    (lpVersionInformation As OSVERSIONINFO) As Long
    _________________________________________

    Public Function GetWinVersion(WIN As RGB_WINVER) As String

    'returns a structure (RGB_WINVER)
    'filled with OS information

    #If Win32 Then

    Dim OSV As OSVERSIONINFO
    Dim pos As Integer
    Dim sVer As String
    Dim sBuild As String

    OSV.OSVSize = Len(OSV)

    If GetVersionEx(OSV) = 1 Then

    'PlatformId contains a value representing the OS
    WIN.PlatformID = OSV.PlatformID

    Select Case OSV.PlatformID
    Case VER_PLATFORM_WIN32s: WIN.VersionName = "Win32s"
    Case VER_PLATFORM_WIN32_NT: WIN.VersionName = "Windows NT"

    Select Case OSV.dwVerMajor
    Case 4: WIN.VersionName = "Windows NT"
    Case 5:
    Select Case OSV.dwVerMinor
    Case 0: WIN.VersionName = "Windows 2000"
    Case 1: WIN.VersionName = "Windows XP"
    End Select
    End Select

    Case VER_PLATFORM_WIN32_WINDOWS:

    'The dwVerMinor bit tells if its 95 or 98.
    Select Case OSV.dwVerMinor
    Case 0: WIN.VersionName = "Windows 95"
    Case 90: WIN.VersionName = "Windows ME"
    Case Else: WIN.VersionName = "Windows 98"
    End Select

    End Select


    'Get the version number
    WIN.VersionNo = OSV.dwVerMajor & "." & OSV.dwVerMinor

    'Get the build
    WIN.BuildNo = (OSV.dwBuildNumber And &HFFFF&)

    'Any additional info. In Win9x, this can be
    '"any arbitrary string" provided by the
    'manufacturer. In NT, this is the service pack.
    pos = InStr(OSV.szCSDVersion, Chr$(0))
    If pos Then
    WIN.ServicePack = Left$(OSV.szCSDVersion, pos - 1)
    End If

    End If

    #Else

    'can only return that this does not
    'support the 32 bit call, so must be Win3x
    WIN.VersionName = "Windows 3.x"
    #End If

    End Function
    ================

    Okay, so apparently that Left$ is preventing the program from compiling, giving me a "Type-declaration character does not match declared data type" error. I don't actually NEED this portion of the function, since it reports the particular service pack installed on an NT/2K/XP machine, but I have run into this problem before, and I suspect it's because of interference from the WinampCOM plugin that's running, since as soon as I disable it, the program compiles just fine.

    It's easy enough to comment or delete this portion out and have it compile and run exactly as expected, but I would sure be interested in knowing why that particular object is no longer valid as long as I'm running that plugin. What could possibly be going on to make a VB object unusable?!?

    Any ideas?
    The ALEXIS Project
    MP3---VIDEO---GPS---REARVIEW---OBD---SKINNING
    Color Coding :
    DONE / MOSTLY DONE / BASE FEATURES / WORKING CONCEPT / NO CODE COMPLETED

  • #2
    Originally posted by deadweasel
    <snip>
    'Any additional info. In Win9x, this can be
    '"any arbitrary string" provided by the
    'manufacturer. In NT, this is the service pack.
    pos = InStr(OSV.szCSDVersion, Chr$(0))
    If pos Then
    WIN.ServicePack = Left$(OSV.szCSDVersion, pos - 1)
    End If

    End If

    <snip>

    "Type-declaration character does not match declared data type" error... and I suspect it's because of interference from the WinampCOM plugin that's running, since as soon as I disable it, the program compiles just fine.
    Any ideas?
    Due to the error, it sounds like you have a variable or function in your WinampCOM plugin that is named "Left" or somewhere in that plugin VB is overloading the declared type. Or maybe I should say VB THINKS you want to overload that type declaration, think misspelled variable or function. I would lean more towards a variable as the error would say something more along the lines of "Too many arguments" or "Not enough arguments" if it was a sub or function.
    Aultl
    [====---] - 65% complete
    Status: Configuring Software
    VIA Epia 800mhz, 256Mb ram, 10Gb HD


    Quote of the Month: "I see the problem, [The RAID controller] is trying to rebuild the array with good data from a failed drive." -- HP Support

    Comment


    • #3
      Originally posted by aultl
      Due to the error, it sounds like you have a variable or function in your WinampCOM plugin that is named "Left" or somewhere in that plugin VB is overloading the declared type. Or maybe I should say VB THINKS you want to overload that type declaration, think misspelled variable or function. I would lean more towards a variable as the error would say something more along the lines of "Too many arguments" or "Not enough arguments" if it was a sub or function.
      That makes sense. Unfortunately, I really have no way to check it out for myself, since this plugin is already compiled and the source is not being released. I had a bit of a lengthy chat with Frodo over this, and he showed me some interesting methods to get around the problem. Bear in mind that this is all pretty much academic anyhow, since I have no use for the portion of the routine that is causing the trouble. Oh well.
      The ALEXIS Project
      MP3---VIDEO---GPS---REARVIEW---OBD---SKINNING
      Color Coding :
      DONE / MOSTLY DONE / BASE FEATURES / WORKING CONCEPT / NO CODE COMPLETED

      Comment


      • #4
        try using just "Left" instead of "Left$"
        Car: 2000 Audi A4 Avant 1.8t
        Carputer 2.0: removed. Back to stock.

        Comment


        • #5
          I was going to suggest using
          WIN.ServicePack = Mid(OSV.szCSDVersion, 1, pos - 1)
          instead rather then waste time trying to find the problem..
          www.DurangoSUV.com

          Comment

          Working...
          X