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: 43
Default mismatch error and Variants

I added an argument to a subroutine and then started getting the By Ref
argument type mismatch error--even though it appears my arguments were of the
right type. I eventually "fixed it" by changing one of the arguments to
Variant rather than Integer. My question is, what's going on here? Why am I
getting a type mismatch when I'm correctly dimensioning my variables?

Here's the call to the sub
GetP WRow, AnIBlk
in which WRow is Dim as Integer, and AnIBlk is Dim as Boolean.

And the Sub itself follows (It's presented in its entirety, although the
subs it calls aren't included). As I said, WRow is declared "As Variant"
because that's the only way I could avoid the mismatch error...when I had it
"As Integer" I got the error every time. The other way I found I could avoid
the error was to declare WRow As Integer globally (that is, at the top of the
module).

I'd appreciate any insights!

Sub GetP(WRow As Variant, AnIBlk As Boolean)

Dim IncAgl() As Double
Dim msg As String
Dim i, j, k, l As Integer
Dim coord As Variant
Dim Pp() As Double

ReDim Preserve Cx(Ncnr + 2) As Double
ReDim Preserve Cy(Ncnr + 2) As Double
ReDim Preserve r(Ncnr) As Double
ReDim IncAgl(Ncnr) As Double

ReDim Pp(2 * Ncnr + 3) As Double
For i = 0 To Ncnr + 1
Pp(2 * i) = Cx(i): Pp(2 * i + 1) = Cy(i)
Next i

For i = 0 To 2 * Ncnr + 3
Cells(WRow + 8, 3 + i) = Pp(i)
Next i

If Not AnIBlk Then

Dim pc(0 To 2) As Double
Dim tc(0 To 2) As Double
Dim nc(0 To 2) As Double
Dim pt As Variant
Dim pla, nlaAs Double
Dim d, ang As Double
Dim bAAs Double
Dim bx() As Double
Dim by() As Double
Dim B() As Double
ReDim bx(2 * Ncnr + 1) As Double
ReDim by(2 * Ncnr + 1) As Double
ReDim B(2 * Ncnr - 1) As Double

For k = 1 To Ncnr
pc(0) = Cx(k - 1): pc(1) = Cy(k - 1): pc(2) = 0
tc(0) = Cx(k + 0): tc(1) = Cy(k + 0): tc(2) = 0
nc(0) = Cx(k + 1): nc(1) = Cy(k + 1): nc(2) = 0

pla = AglX(tc, pc)
nla= AglX(tc, nc)
IncAgl(k) = pla - nagl
If IncAgl(k) < 0 Then IncAgl(k) = 2 * pi + IncAgl(k)

d = Abs(r(k) / Tan(IncAgl(k) / 2))
ang = pla

bx(2 * k - 1) = Ppx(tc, ang, d)
by(2 * k - 1) = Ppy(tc, ang, d)
d = Abs(r(k) / Tan(IncAgl(k) / 2)) 'see figure
ang = nagl

bx(2 * k) = Ppx(tc, ang, d)
by(2 * k) = Ppy(tc, ang, d)
'Set lineObj = ThisDwg.ModelSpace.AddLine(tc, pt)
Next k

bx(0) = Cx(0): by(0) = Cy(0)
bx(2 * Ncnr + 1) = Cx(Ncnr + 1): by(2 * Ncnr + 1) = Cy(Ncnr + 1)

ReDim Pp(4 * Ncnr + 3) As Double

For i = 0 To 2 * Ncnr + 1
Pp(2 * i) = bx(i): Pp(2 * i + 1) = by(i)
Next i

For i = 1 To 2 * Ncnr - 1 Step 2
k = (i + 1) / 2
bA= Tan((pi - IncAgl(k)) / 4)
B(i) = bAmt
Next i

For i = 0 To 2 * Ncnr + 1
Cells(WRow + 9, 3 + 2 * i) = bx(i)
Cells(WRow + 9, 4 + 2 * i) = by(i)
Next i
For i = 1 To 2 * Ncnr - 1 Step 2
Cells(WRow + 10, 3 + i) = B(i)
Next i
End If

End Sub

 
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
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
xpath error? Runtime Error 13 type mismatch Steve M[_2_] Excel Discussion (Misc queries) 0 January 17th 08 01:16 AM
xpath error? Runtime Error 13 type mismatch SteveM Excel Discussion (Misc queries) 1 December 4th 07 09:16 AM
Type Mismatch error & subscript out of range error Jeff Wright[_2_] Excel Programming 3 May 14th 05 07:14 PM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM


All times are GMT +1. The time now is 06:34 AM.

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"