Note that there are some explanatory texts on larger screens.

plurals
  1. POVB6 - ByRef argument type mismatch error - where is it?
    primarykey
    data
    text
    <p>For the 10+ years I've been using VB6, every now and then I get a "ByRef argument type mismatch" error where I simply can't find the mismatch. After struggling for a while I've always punted by forcing the type one way or another, but this time I thought I'd ask. I'm including all the code I think could have anything to do with this; but you can skip it now and refer to it after I demonstrate the problem:</p> <pre>Public Type PBufferType Location(9) As Integer ' code location ValueHi(9) As Integer ' Vhi code ValueLo(9) As Integer ' Vlo code Locked(9) As Integer ' State of pair Gamma(9) As Single ' Gamma between this segment and next End Type Public GammaBuffer(1) As PBufferType ' The main data type Public SelectedBank as Integer Function MeasureLuxAtCode(code As Integer) As Single Call TestPatternForm.DrawTestWindow(3, code) MeasureLuxAtCode = MeasureLux(1) End Function </pre> <p>The problem occurs below. The "LuxMinTarget = MeasureLuxAtCode(FirstLevel)" line generates a "ByRef argument type mismatch" error, indicating that FirstLevel is not an integer.</p> <pre> Sub DetermineIdealLuxCurve() Dim FirstLevel, FirstDACtoMeasure As Integer FirstDACtoMeasure = 0 FirstLevel = GammaBuffer(SelectedBank).Location(FirstDACtoMeasure) LuxMinTarget = MeasureLuxAtCode(FirstLevel) End Sub </pre> <p>But dang it, FirstLevel <em>is</em> an integer, isn't it? It's dim'ed an int, its value is set by a UDT that returns an int, so where did I go wrong? If I force it to an int like this:</p> <pre> LuxMinTarget = MeasureLuxAtCode(Int(FirstLevel)) </pre> <p>the compiler/interpreter's happy. But I'm not.</p> <p>So is this a bug in the compiler or just me being dense?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload