change string into an integer

Michiel Spape Michiel.Spape at nottingham.ac.uk
Mon Aug 23 08:37:58 UTC 2010


Hi Mark & group,
I understand that string InitialValue takes a value from attribute InitialValue (i.e. [InitialValue]), which in turn refers to nested attribute [Value02]? 
1. Why do you not just have vCount = c.GetAttrib("Value02")?
2. Attributes themselves are like (or just are?) variants, which VisualBasic slightly awkwardly casts depending on their value. Point is:
Dim vCount as integer
vCount = c.GetAttrib ("InitialValue")
vCount = vCount + 1 'or whatever you do with your intial value
c.SetAttrib "InitialValue", vCount
...should also work, as long as the value of [initialvalue] actually was found to be a number
3. All of that should hardly matter, but if vCount has value of "Value02" (rather than [Value2]), my quick guess would be that your nested attribute is wrongly set to be Value02 instead of Value02. So:
vCount = c.GetAttrib("InitialValue") 'is where it goes wrong
...adding the following line should give you a quick check to see whether this is tru:
debug.print cstr(vCount) 'shows value in output log.
If this shows a) nothing at all, or b) a value that is not a number (like 'Value02'), then quite obviously, you cannot change this into an integer. Although, if you like, you can change Value02 into an integer of 02 (i.e. 2) by doing something like 
Dim newvalue as integer
Newvalue = cint(mid(vCount,6,2))
(not sure on exact syntax)

Best,
Mich

Michiel Spapé
Research Fellow
Perception & Action group
University of Nottingham
School of Psychology


-----Original Message-----
From: e-prime at googlegroups.com [mailto:e-prime at googlegroups.com] On Behalf Of Matt Paffel
Sent: 20 August 2010 20:28
To: E-Prime
Subject: change string into an integer

I have a question regarding the changing logged data from a string
into an integer. I have a little bit of script before a label which
designates the starting values in a trial which is:

Dim vCount As String
Dim pCount As String
Dim InitialValue As String
Dim InitialPie As String
vCount = c.GetAttrib("InitialValue")
pCount = c.GetAttrib("InitialPie")

at the end of a second inline, this little bit of script logs the data
designated in the first.

c.SetAttrib "InitialValue", vCount
c.SetAttrib "InitialPie", pCount

pCount is fine but vCount logs value of Value02, which is a nested
attribute. I would like to have it return the value contained in the
attribute "Value02". I've tried to make this happen a number of
different ways, e.g. CInt(vCount), CStr(CInt(vCount) + 0), etc.) but
each time i get an error message of type mismatch. is there any way to
change this string into an integer?

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.

This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it.   Please do not use, copy or disclose the information contained in this message or in any attachment.  Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.

This message has been checked for viruses but the contents of an attachment
may still contain software viruses which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.



More information about the Eprime mailing list