Results 1 to 3 of 3

Thread: What's wrong with this code

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 1999
    Posts
    34

    Post

    Hi, I'm trying to get some old code working (it's been converted from VB3 binary format).

    i've had a few problems but managed to solve them but the latest one is puzzling me (i'm a bit of a beginner).

    when i try to run the program i get the error message

    Runtime error '6':
    overflow

    and the piece of code
    chk = Shell(ret, 8)
    is highlighted when i click the debug button

    the function is shown below

    does anyone have any ideas
    thanks in advance
    MICK

    Private Function StartAcad() As Integer

    Dim ret$
    Dim nSize%, chk%, chk2%

    ret = String$(145, Chr$(0))
    nSize = Len(ret)
    chk2 = True

    chk = GetPrivateProfileString("AUTOCAD", "EXEPATH", "", ret, nSize, INI_path)

    If chk = 0 Then
    MsgBox "Unable to start AutoCAD, check PLOTLOG.INI for validity."
    chk2 = False
    Else
    chk = Shell(ret, 8)
    End If

    StartAcad = chk2
    End Function

  2. #2
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386

    Post

    Allmost all Win32 API's are changed from integer to long... change the declarations of the integers to long and it should work (at least no overflow error...)

  3. #3
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    You need a double or variant variable to receive the return value of the SHELL function:

    from MSDN:


    Shell Function

    Runs an executable program and returns a Variant (Double) representing the program's task ID if successful, otherwise it returns zero.
    So change that % to a #

    Better yet, explicitly declare the data types instead of using those old-fashioned operators, so the next programmer won't want to strangle you.

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