Erin,
Sigh. Please, please, please folks: (1) Do *not* apply any
formatting to text in your posts, it makes it illegible in some
e-mail readers. Just use plain text. (2) OTOH, *do* indent your
code fragments for readability, e.g.,
If Stimulus.RESP = 1 Then
nPoints = nPoints + 1
Else
nPoints = nPoints + 0
End If
c.SetAttrib "CurrentPoints", nPoints
Now, to start with, why in the world would you have a line like
nPoints = nPoints + 0
which produces absolutely no effect?! The following simplified code
would do the same:
If (Stimulus.RESP = 1) Then nPoints = nPoints + 1
c.SetAttrib "CurrentPoints", nPoints
Now, to your problem. The RESP property of Stimulus has type String,
not Integer. Because VBA/E-Basic, when possible, does automatic type
conversion (which just allows programmers to get sloppy), that works
fine as long as RESP happens to contain text that will convert to an
integer. But when you get no response, RESP contains the null sting
"", and that does *not* convert to an integer. Thus, the "Type
Mismatch" error, easily understood by those of us who grew up with
proper strongly-typed languages (e.g., Fortran, Pascal, C).
The solution? Here are better tests for *presence* of a response:
- If (x.RESP <> "") ...
- If (Len(x.RESP) > 0) ..., or, If Len(x.RESP) ...
- If (x.RTTime <> 0) ..., or, If (x.RTTime) ...
- If (x.InputMasks(1).Count > 0) ...,
or, If x.InputMasks(1).Count ... (but only for given mask)
Simply invert these to make tests for *absence* of a response. And
as indicated by these examples, because VBA/E-Basic treats 0 as False
and any non-0 value as True, in some cases you need not make the
comparison test explicit (although most users may find that
discomforting). (I used to also include the test "If (x.RT) ...",
but I recently discovered that, in the unlikely case that RTTime =
OnsetTime, RT would be 0 even with a response.)
So in your case, this comes down to just, e.g.,
If Stimulus.RTTime Then nPoints = nPoints + 1
c.SetAttrib "CurrentPoints", nPoints
-----
David McFarlane
E-Prime training
online:
http://psychology.msu.edu/Workshops_Courses/eprime.aspx
Twitter: @EPrimeMaster (
https://twitter.com/EPrimeMaster)
/----
Stock reminder: 1) I do not work for PST. 2) PST's trained staff
take any and all questions at
http://support.pstnet.com/e%2Dprime/support/login.asp , and they
strive to respond to all requests in 24-48 hours -- this is pretty
much their substitute for proper documentation, so make full use of
it. 3) In addition, PST takes questions at their Facebook page
(
http://www.facebook.com/pages/Psychology-Software-Tools-Inc/241802160683
), and offers several instructional videos there and on their YouTube
channel (
http://www.youtube.com/user/PSTNET ) (no Twitter feed yet,
though). 4) If you do get an answer from PST staff, please extend
the courtesy of posting their reply back here for the sake of others.
\----