|
-
Oct 19th, 2005, 05:45 AM
#1
Thread Starter
Lively Member
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:
Public Function DoubleClick(Socket As Integer, rcvData() As Byte)
On Error GoTo Error_Handle
Dim Target As Long, mItem As TypeItem
Target = GetTarget(rcvData, 1)
If Target = -1 Then Exit Function
If Target <= UBound(Character) Then
If Character(Target - CharSerialOffset).CharacterType = CTPlayer Or CTVendor Then
Paperdoll Socket, Target - &H80000000
End If
If Character(Target - CharSerialOffset).CharacterType = CTMount Then
If CheckIfLayerInuse(Client(Socket).Serial, LMount) = True Then
Exit Function
Else
Character(Target).Flag.Invisible = True
Character(Target).Flag.Frozen = True
With mItem
.Amount = 1
.ParentSerial = Client(Socket).Serial
.Name = "a mount"
.CurrentLocation = Character(Client(Socket).Serial).CurrentLocation
.ItemID = Character(Target).TameDetails.MountID
.Hue = Character(Target).SkinHue
.Layer = 25
.Owner = Client(Socket).Serial
.Misc = Target
.Serial = UBound(Item) + 1 + ItemSerialOffset
End With
AddItembyInfo mItem
UpdateItem (UBound(Item) + ItemSerialOffset)
UpdateInRangeNPC (Target)
End If
End If
Else
If Character(Client(Socket).Serial).Flag.Dead = True Then
If Server.Era < AOS Then
'Send 'I am dead and cannot do that.'
Else
Cliloc Socket, Client(Socket).Serial, 0, 3000061, AbovePlayer
End If
Exit Function
Else
If Item(Target - ItemSerialOffset).ItemType = ITContainer And IsInRange(Client(Socket).Serial, Target - ItemSerialOffset, 3, True) = True And Item(Target - ItemSerialOffset).Gump > 0 Then
If Item(Target - ItemSerialOffset).ParentSerial = 0 Or Client(Socket).Serial Then
If IsInRange(Client(Socket).Serial, Target - ItemSerialOffset, 3, True) = True And IsItemInview(Client(Socket).Serial, Target - ItemSerialOffset) = True Then
ShowContainer Socket, (Target)
Else
If Server.Era < AOS Then
'Send 'I can't reach that.'
Else
Cliloc Socket, Client(Socket).Serial, 0, 1019045, AbovePlayer
End If
End If
Else
'If IsInRange(Client(Socket).Serial, (Target - ItemSerialOffset), 1, True) Then useskill Socket, Snooping, Target
End If
End If
End If
End If
Exit Function
Error_Handle:
frmMain.lstStatus.AddItem "WARNING: Double Click Error. Crash caused with error(" & Err.Description & ")" & Err.Source
frmMain.lstStatus.ListIndex = frmMain.lstStatus.ListCount - 1
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??
-
Oct 19th, 2005, 05:46 AM
#2
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.
-
Oct 19th, 2005, 05:54 AM
#3
Thread Starter
Lively Member
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
-
Oct 19th, 2005, 06:02 AM
#4
Re: Error only occurs when compiled??
 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?
-
Oct 19th, 2005, 06:04 AM
#5
Thread Starter
Lively Member
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??
-
Oct 19th, 2005, 06:05 AM
#6
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:
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.
-
Oct 19th, 2005, 09:27 AM
#7
KING BODWAD XXI
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.
-
Oct 19th, 2005, 09:45 AM
#8
Re: Error only occurs when compiled??
 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.
-
Oct 19th, 2005, 10:03 AM
#9
Hyperactive Member
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
at the top of the module will prevent you from passing Long values to Integer parameters.
-
Oct 19th, 2005, 10:46 AM
#10
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.
-
Oct 19th, 2005, 10:46 AM
#11
Thread Starter
Lively Member
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.
-
Oct 19th, 2005, 12:26 PM
#12
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|