LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default Evaluate error when using 2

This is the weirdest thing I've ever seen. I have several strings that
contain either a number or a mathmatical expression. I set variables equal
to the solution of the expression or the number using the Evaluate method on
each string.

When the string evaluated is "2" the code bombs.

Here's the section of code:

Sub quad()
Dim a, b, c, d
Dim temp(3) As String
Set rng4 = rng1.Cells.Find(what:="p1", LookIn:=xlValues, lookat:=xlPart)
If Not rng4 Is Nothing Then
For i = 0 To 3
temp(i) = Mid(rng4.Offset(i, 0), InStr(1, rng4.Offset(i, 0), """", 1) + 1)
temp(i) = Left(temp(i), Len(temp(i)) - 1)
Next
a = Split(temp(0), """, """, -1)
b = Split(temp(1), """, """, -1)
c = Split(temp(2), """, """, -1)
d = Split(temp(3), """, """, -1)
Cells(2, 5).Value = a(0) + a(1) + a(2)
For j = 0 To 2
a(j) = Evaluate(a(j))
b(j) = Evaluate(b(j))
c(j) = Evaluate(c(j))
d(j) = Evaluate(d(j))
a(j) = CDbl(a(j))
b(j) = CDbl(b(j))
c(j) = CDbl(c(j))
d(j) = CDbl(d(j))
Next
If a(2) = b(2) And a(2) = c(2) And a(2) = d(2) Then
NodeArea = ((c(0) - a(0)) * (d(1) - b(1)) - (d(0) - b(0)) * (c(1) -
a(1))) / 2
Else
NodeArea = "This quadrilateral is not 2-Dimensional"
End If
Else
End If
nodes 'Calls the funtion that determines the first node
output
End Sub


The code finds a cell that starts with 'p1' and then pulls the data out of
the next three cells as well.

Here is a sample of the text it reads:

quadrilateral quadrilateral.1
units = meters
p1 = "0.0", "0.0", "0.0"
p2 = "2", "0.0", "0.0"
p3 = "1.0", "1.0", "0.0"
p4 = "0.0", "1.0", "0.0"
active = BOTH sides = SINGLE submodel = MAIN include = RADK,CC
initial_id = "4"
iconductor = "1"
ngamma = "1"
rot1 = x,"0.000000" rot2 = y,"0.000000" rot3 = z,"0.000000" tx = "-1.000000"
ty = "-0.500000" tz = "0.000000"
optics = "default_prop", "default_prop"
optics_angles = "0.0", "0.0"
material = "default_mat" thickness = "0.1"
color = Pink
initial_temp = "21.111111", Celsius

For the above text, the code bombs at p2 with the following error message:
"run-time error '438': object doesn't support this property or method"

If I change the p2 text to read any of the following, the code works fine:
p2 = "2.0", "0.0", "0.0"
p2 = "2.", "0.0", "0.0"
p2 = "+2", "0.0", "0.0"
p2 = "2+0", "0.0", "0.0"

This only happens when the string is "2". No other number causes this error.

Anyone have any ideas?

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
evaluate afdmello Excel Worksheet Functions 3 May 16th 10 09:11 PM
Evaluate function Stefi Excel Worksheet Functions 7 November 21st 07 12:50 PM
Might be a bug in Evaluate Formula? cyx Excel Discussion (Misc queries) 2 May 2nd 07 10:52 PM
evaluate #¡VALUE! and #!DIV/0! and other errors.... jamiguel77 Excel Worksheet Functions 1 February 14th 06 07:13 AM
evaluate HYPERLINK() rabbit ribbit Excel Worksheet Functions 1 March 2nd 05 12:09 PM


All times are GMT +1. The time now is 02:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"