Runtime Error 380?

I get a Runtime Error 380, and it highlights this in ModGameEditors:

frmEditor_Item.chkPierce.Value = .Armor

I have that declared in ModTypes, under the ItemRec as a Boolean on both the client and the server.

This happens when I am in game when I access the item editor for the one item that I had checked (true’d) the chkbox for.

And the code for that chkbox is as follows:

Private Sub chkPierce_Click()

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

If chkPierce.Value = 0 Then

	 chkPierce.Caption = "Pierce: No"

ElseIf chkPierce.Value = 1 Then

	 chkPierce.Caption = "Pierce: Yes"

End If

Item(EditorIndex).Armor = chkPierce.Value

errorhandler:

HandleError "chkPierce_Click", "frmEditor_Item", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

Although I can’t see that being the problem - it does only happen when this chkbox and it’s _Click code is present on the form. What am I missing?

I was under the impression that check boxes were those weird components in vb6 where you used .checked (true/false) rather than value because value didn’t actually work right…

Should I just swap out the chkbox for a scrlbar? .Min = 0 and .Max=1? That should still work with a boolean, right?

Should I just swap out the chkbox for a scrlbar? .Min = 0 and .Max=1? That should still work with a boolean, right?

Yea that will work.

Checkboxes have 3 values. 0 = grayed, 1 = unchecked, 2 = checked. So setting a value of greater than 1 to a boolean value will generate an error. You can use a select case and check if the value of the checkbox is 1 or 2 and subtract the value with 1 and save it as a boolean (since false = 0 and true = 1) Or you can just change the boolean to a byte and the rest will be done for you.

Checkboxes have 3 values. 0 = grayed, 1 = unchecked, 2 = checked.

0 = unchecked/false

1 = checked/true

2 = grayed

Anyways, the issue lies with the .Armor value because the checkbox can only contain 0 or 1. If you try to assign the checkbox’s value to anything less than that or higher than that, it will bring up a RTE 380. When the RTE comes up, hover your mouse over .Armor and you’ll see the value being assigned to the checkbox.

Yea that will work.

Checkboxes have 3 values. 0 = grayed, 1 = unchecked, 2 = checked. So setting a value of greater than 1 to a boolean value will generate an error. You can use a select case and check if the value of the checkbox is 1 or 2 and subtract the value with 1 and save it as a boolean (since false = 0 and true = 1) Or you can just change the boolean to a byte and the rest will be done for you.

I thought that grayed=2. So that’s why. Gonna try it out in a bit.

Well wait, that can’t be. Because I did the same thing for NpcRec, added as a Boolean. I did everything the same, and there are no errors for that…hmmm…

0 = unchecked/false

1 = checked/true

2 = grayed

thanks. I knew mine was wrong.

See, if 0 = unchecked/false, and 1 = checked/true, there shouldn’t be any error, right? The checkbox value is never set to 2/grayed by the user.

This also only happened AFTER I had checked an item with the .armor (piercing) attribute. After that, upon selecting it from the list it gives me the error. I can still select and view the info/change the info for all other items. I can even change the state of the checkbox. But if it is checked, and I go back to check it, I get the 380.

I wonder if order I place the code in, under the ModGameEditor module, is the issue?

When the RTE comes up, hover your mouse over .Armor and you’ll see the value being assigned to the checkbox. Post that number here.

OR

You could send me your source, and I’ll (try) to fix it for you. You have my word that I won’t steal anything you send. ^_^

I have since changed the Pierce and Armor variables to Long, and now to Byte. My Armor works on NPCs, not errors at all. But my variables for Pierce always give me an error. Now I get one constantly.

I get error 380:

frmEditor_Item.scrlPierce.Value = .Pierce
```is highlighted within ModGameEditors

Mouseover the first half gives me:

frmEditor_Item.scrlPierce.Value = 0


Mouseover .Pierce gives me:

.Pierce = 255


When it was a Long variable, it gave me an overflow with .Pierce = 66555 or whichever specific number it was. So what is causing this to happen? I now have a scrlPierce, min = 0, max = 1

Private Sub scrlPierce_Change()

’ If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

If EditorIndex = 0 Or EditorIndex > MAX_ITEMS Then Exit Sub

If scrlPierce.Value = 0 Then

    lblPierce.Caption = "Pierce: No"

ElseIf scrlPierce.Value = 1 Then

    lblPierce.Caption = "Pierce: Yes"

End If

Item(EditorIndex).Pierce = scrlPierce.Value

' Error handler

Exit Sub

errorhandler:

HandleError "scrlPierce_Change", "frmEditor_Item", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub


Anything look suspicious to anyone?

When it was a Long variable, it gave me an overflow with .Pierce = 66555 or whichever specific number it was. So what is causing this to happen? I now have a scrlPierce, min = 0, max = 1

If the max is 1, then of course an overflow RTE comes up.

As I previously mentioned, and if you want, send me your source and I’ll fix it for you.

But that makes no sense, because I have another scrlbar for NPC’s Armor, and that works perfectly with the max value set to 1.

And I’d like to learn this stuff myself, instead of having somebody do it for me.

Do you have teamviewer? I could help you out on that.

No I don’t, and at the moment have no interest in it. I appreciate the help, but I’d rather not somebody else just fix my code. I want to learn why it’s acting the way it is, otherwise I won’t get any better.

I just want to know why that variable keeps getting flooded as it is. There has to be some reason. The NPC version has an almost identical structure (sans replacing Item with NPC), and it works perfectly. It can’t be that the scroll-bar’s maximum value is set to 1, why would that overflow the variable? That doesn’t make sense - mostly because it should only go up to 1 - but also because I have another scroll-bar with a maximum value set to 1, and that works.

[Edit]I figured it out. Everything is working now, and I’m pretty sure I understand why too.[/edit]

I want to learn why it’s acting the way it is, otherwise I won’t get any better.

I’m glad you want to learn!

Its easier for me to figure out what’s going wrong when I have the source in VB6. You wouldn’t be figuring it out on your own if we told you why its being flooded, and pointing that out on TeamViewer isn’t any different. Regardless, I’m glad you fixed it.

Log in to reply