Results 1 to 12 of 12

Thread: Error only occurs when compiled??

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2004
    Posts
    102

    Error only occurs when compiled??

    Lo all,
    Im making a program which works fine while in development running (ie pressing f5 while coding) but when I turn it into an .exe I get an error where I didnt get one previously. Does anyone have any ideas?? Heres the code throwing up the error.

    VB Code:
    1. Public Function DoubleClick(Socket As Integer, rcvData() As Byte)
    2.     On Error GoTo Error_Handle
    3.     Dim Target As Long, mItem As TypeItem
    4.     Target = GetTarget(rcvData, 1)
    5.     If Target = -1 Then Exit Function
    6.     If Target <= UBound(Character) Then
    7.         If Character(Target - CharSerialOffset).CharacterType = CTPlayer Or CTVendor Then
    8.             Paperdoll Socket, Target - &H80000000
    9.         End If
    10.         If Character(Target - CharSerialOffset).CharacterType = CTMount Then
    11.             If CheckIfLayerInuse(Client(Socket).Serial, LMount) = True Then
    12.                 Exit Function
    13.             Else
    14.                 Character(Target).Flag.Invisible = True
    15.                 Character(Target).Flag.Frozen = True
    16.                 With mItem
    17.                     .Amount = 1
    18.                     .ParentSerial = Client(Socket).Serial
    19.                     .Name = "a mount"
    20.                     .CurrentLocation = Character(Client(Socket).Serial).CurrentLocation
    21.                     .ItemID = Character(Target).TameDetails.MountID
    22.                     .Hue = Character(Target).SkinHue
    23.                     .Layer = 25
    24.                     .Owner = Client(Socket).Serial
    25.                     .Misc = Target
    26.                     .Serial = UBound(Item) + 1 + ItemSerialOffset
    27.                 End With
    28.                 AddItembyInfo mItem
    29.                 UpdateItem (UBound(Item) + ItemSerialOffset)
    30.                 UpdateInRangeNPC (Target)
    31.             End If
    32.         End If
    33.     Else
    34.         If Character(Client(Socket).Serial).Flag.Dead = True Then
    35.             If Server.Era < AOS Then
    36.                 'Send 'I am dead and cannot do that.'
    37.             Else
    38.                 Cliloc Socket, Client(Socket).Serial, 0, 3000061, AbovePlayer
    39.             End If
    40.             Exit Function
    41.         Else
    42.             If Item(Target - ItemSerialOffset).ItemType = ITContainer And IsInRange(Client(Socket).Serial, Target - ItemSerialOffset, 3, True) = True And Item(Target - ItemSerialOffset).Gump > 0 Then
    43.                 If Item(Target - ItemSerialOffset).ParentSerial = 0 Or Client(Socket).Serial Then
    44.                     If IsInRange(Client(Socket).Serial, Target - ItemSerialOffset, 3, True) = True And IsItemInview(Client(Socket).Serial, Target - ItemSerialOffset) = True Then
    45.                         ShowContainer Socket, (Target)
    46.                     Else
    47.                         If Server.Era < AOS Then
    48.                             'Send 'I can't reach that.'
    49.                         Else
    50.                             Cliloc Socket, Client(Socket).Serial, 0, 1019045, AbovePlayer
    51.                         End If
    52.                     End If
    53.                 Else
    54.                     'If IsInRange(Client(Socket).Serial, (Target - ItemSerialOffset), 1, True) Then useskill Socket, Snooping, Target
    55.                 End If
    56.             End If
    57.         End If
    58.     End If
    59.     Exit Function
    60. Error_Handle:
    61.     frmMain.lstStatus.AddItem "WARNING: Double Click Error. Crash caused with error(" & Err.Description & ")" & Err.Source
    62.     frmMain.lstStatus.ListIndex = frmMain.lstStatus.ListCount - 1
    63. End Function

    The error im getting is an 'overflow' error, I dont know where its occuring as no error is thrown up if I do step through or run from vb6 play button/f5. The error only occurs when I run the .exe after a full compile. Any ideas??

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Error only occurs when compiled??

    From the IDE, instead of hitting F5, do Ctrl+F5...that will do a Run With Full Compile.

    It will blow up on the line giving you the error and a message box will pop up. Hit the Debug button and you will be taken directly to the line causing the error.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2004
    Posts
    102

    Re: Error only occurs when compiled??

    really stupid that Ive been doing vb for quite a few number of years and Ive seen that in the menu and allways wondered what it was and never bothered to find out lol. thx.

    [EDIT]
    Just tried it then, didnt throw up any errors but with same code still getting the errors from .exe

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Error only occurs when compiled??

    Quote Originally Posted by Dilvid
    Just tried it then, didnt throw up any errors but with same code still getting the errors from .exe
    That is very, very odd. Run With Full Compile should perform the exact same function as Make .Exe with the exception that no .Exe is made. Any errors during compile time should show up in Full Compile.

    When you do the Make .Exe and it hits the spot it doesn't like, doesn't it highlight the line?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2004
    Posts
    102

    Re: Error only occurs when compiled??

    Right Ive had a small break through. When Compiling to the .exe I get the error when compiling with the option 'optimize for fast code' but I dont get the error occuring when I compile to 'no optimizations'. Is this a vb6 error and not my code??

  6. #6
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: Error only occurs when compiled??

    You might try adding line numbers and the display erl function to your error handling routine. That might give to the line number. Something like:

    VB Code:
    1. MsgBox "Error Help Command at Line # " & Erl & " (" & Err.Description & ")", , "Error: cmdHelp_Click"

    Check out www.mztools.com for a tool to add and remove line numbers to code easily. If you just want them for this problem add then in manually.

  7. #7
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176

    Re: Error only occurs when compiled??

    Make sure you arent using different data files for the exe. Could be an entry in an external file thats causing the trouble.
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Error only occurs when compiled??

    Quote Originally Posted by Dilvid
    Right Ive had a small break through. When Compiling to the .exe I get the error when compiling with the option 'optimize for fast code' but I dont get the error occuring when I compile to 'no optimizations'. Is this a vb6 error and not my code??
    He seems to have correctly identified the issue.

    No, this is not a VB6 error at all. What Optimize for Fast Code does is maximize the speed of compiled executable files by instructing the compiler to elect speed over size.

    When the compiler translates Visual Basic statements into machine code, which is what a compiler does, there are often a variety of pieces of machine code that can correctly represent a given statement. Sometimes these varities can result in a trade-offs of size of compiled .exe versus the speed of a compiled exe. Selecting this option tells the compiler that you want it to always generate the fastest code sequence possible, even when that may increase the size of the compiled program.

    I don't see why that would have a bearing on something generating an error or not generating an error, but this seems to be the case. So, leave it at no optimizations.

  9. #9
    Hyperactive Member umilmi81's Avatar
    Join Date
    Sep 2005
    Location
    Sterling Heights, Mi.
    Posts
    335

    Re: Error only occurs when compiled??

    My guess is that you're running on two different sets of data.

    When you're running in debug mode you are using a small test set of data. When you are running in EXE you are running against a larger set of data.

    Make sure you're not overflowing the Character and Client arrays

    Also make sure IsItemInview and IsInRage have parameters that support the appropriate size numbers.

    I *think* putting
    VB Code:
    1. Option Explicit

    at the top of the module will prevent you from passing Long values to Integer parameters.

  10. #10
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Error only occurs when compiled??

    Right Ive had a small break through. When Compiling to the .exe I get the error when compiling with the option 'optimize for fast code' but I dont get the error occuring when I compile to 'no optimizations'. Is this a vb6 error and not my code??
    I've seen this problem a couple of times in the past with code I'd written.
    It's got to be a bug in the VB6 compiler.

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Jul 2004
    Posts
    102

    Re: Error only occurs when compiled??

    Its actually at the top of every single module I have. I dont think its using other data aswell since its a server for a game. So I connect using the client while in 'debug mode' and get no error but when I compile full and connect using the same client it throws the error up.

    I also found that if I use compile with fast code optimization and do advanced and check the 'remove integer oferflow check' I dont get the error. I think its kinda strange as Im using Long not Integer lol.

  12. #12
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Error only occurs when compiled??

    You call several procedures from the one that you show. If you don't have error handling in one or more of them then the overflow error could actually be happening in one of them.

    It's also been my experience that the error-in-the-exe-but-not-in-the-IDE problem is most often caused by some long and/or external process that doesn't get a chance to finish before before VB rushes on in the exe. The problem is often fixed by adding a DoEvents statement near or in the process so that the process gets a chance to finish.

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