C
crazybass2
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?
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?