Results 1 to 5 of 5

Thread: Can't compile a VB program because of $Left

  1. #1
    Maximum Bitrate deadweasel's Avatar
    Join Date
    Nov 2003
    Location
    Detroit MI
    Posts
    886

    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. #2
    Low Bitrate aultl's Avatar
    Join Date
    Sep 2003
    Location
    Tennessee
    Posts
    110
    Quote 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

  3. #3
    Maximum Bitrate deadweasel's Avatar
    Join Date
    Nov 2003
    Location
    Detroit MI
    Posts
    886
    Quote 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

  4. #4
    Maximum Bitrate brrman's Avatar
    Join Date
    Aug 2003
    Location
    Indianapolis, IN USA
    Posts
    523
    try using just "Left" instead of "Left$"
    Car: 2000 Audi A4 Avant 1.8t
    Carputer 2.0: removed. Back to stock.

  5. #5
    Variable Bitrate
    Join Date
    Sep 2003
    Location
    Wilkes Barre, Pa
    Posts
    233
    I was going to suggest using
    WIN.ServicePack = Mid(OSV.szCSDVersion, 1, pos - 1)
    instead rather then waste time trying to find the problem..

Similar Threads

  1. Problems with VB program as external app
    By zolakk in forum ME Archive
    Replies: 3
    Last Post: 07-09-2003, 10:36 PM
  2. Looking for a program.
    By Mikesz in forum Software & Software Development
    Replies: 1
    Last Post: 11-23-2002, 06:09 AM
  3. Running a program inside a program
    By CaffeineAddict in forum Software & Software Development
    Replies: 10
    Last Post: 10-16-2002, 03:26 AM
  4. charchter lcd program?
    By Jaymz in forum Software & Software Development
    Replies: 1
    Last Post: 02-15-2001, 07:32 PM
  5. Can someone write me a PIC program 4 a awesome s/down controller please?
    By gizmos in forum General Hardware Discussion
    Replies: 3
    Last Post: 07-17-2000, 12:43 PM

Bookmarks

Posting Permissions

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