 |

09-20-2005, 08:14 AM
|
|
Freshman
|
|
Join Date: Sep 2005
Posts: 34
|
|
function question
|
Is there a depth as to how many times a variable can be passed through functions.
for example, I have a function I made called:
rdsp(screen_name, x, y, x2, y2)
where screen_name is the name of a terminal where I am getting information from those x/y specified coordinates.
I use this rdsp function for other functions with inturn use it for even more functions and so on.
but now I get a
Runtime error 13 when trying to assign a variable to the screen_name
screenstr = CStr(screen & ".dsp") 'gets runtime error 13
I think at most, the depth of the functions is about 3-5 passes
using vb 2003 in microsoft excel
|
|

09-20-2005, 09:18 AM
|
 |
Regular
|
|
Join Date: Mar 2004
Location: Buenos Aires, Argentina
Posts: 56
|
|
|
They have no limit more than the stack. All parameters are written in a stack, such as all calls. If you fill the stack, the error will be: "Stack overflow"
|
__________________
Excuse my English
¡VB Destroy your mind!
|

09-20-2005, 10:16 AM
|
|
Freshman
|
|
Join Date: Sep 2005
Posts: 34
|
|
|
alright, then is there some magical trick to getting optional arguments in functions working, because I'm trying to evaluate a string against a string for an optional variable, and I keep getting error 13 type mismatch
|
|

09-20-2005, 10:23 AM
|
 |
Green-Eyed
Super Moderator * Guru *
|
|
Join Date: May 2001
Location: Bangkok, Thailand
Posts: 10,261
|
|
|
Post the full procedure and we'll take a look.
|
|

09-20-2005, 01:36 PM
|
|
Freshman
|
|
Join Date: Sep 2005
Posts: 34
|
|
well, alright
Code:
Function r_Is(Optional shortname, Optional ScreenArray)
Dim a
If IsMissing(shortname) = True And IsMissing(ScreenArray) = False Then GoTo movingon
If IsMissing(shortname) = False And IsMissing(ScreenArray) = True Then GoTo movingon
If IsMissing(shortname) = True And IsMissing(ScreenArray) = True Then GoTo movingon
r_Is = False
GoTo donedone
movingon:
evaluate00:
If IsArray(ScreenArray) Then
a = ScreenArray
Else
a = xlr(1, 1, 24, 80)
End If
r_Is = False 'default 'taking out default, boolean errors?
If r_Is_Blank(a) Then r_Is = "blank"
If r_Is_CHIST00(a) Then r_Is = "chist00"
If r_Is_CHIST01(a) Then r_Is = "chist01"
If r_Is_CHIST02(a) Then r_Is = "chist02"
If r_Is_CHIST02pf11(a) Then r_Is = "chist02pf11"
If r_Is_CHIST03(a) Then r_Is = "chist03"
If r_Is_CHIST04(a) Then r_Is = "chist04"
If r_Is_CHIST05(a) Then r_Is = "chist05"
If r_Is_CHIST05pf11(a) Then r_Is = "chist05pf11"
If r_Is_CHIST06(a) Then r_Is = "chist06"
If r_Is_CHIST07(a) Then r_Is = "chist07"
If r_Is_clOVR00(a) Then r_Is = "clovr00"
If r_Is_clOVR01(a) Then r_Is = "clovr01"
If r_Is_clOVR02(a) Then r_Is = "clovr02"
If r_Is_ITFI00(a) Then r_Is = "itfi00"
If r_Is_XAofDF(a) Then r_Is = "xaofdf"
'MsgBox IsMissing(shortname)
If IsMissing(shortname) = False Then
If r_Is = False Then GoTo evaluate00
If r_Is = shortname Then GoTo donedone 'run-time error 13 right here
GoTo evaluate00
End If
donedone:
End Function
Edit by Moderator:
Please use the [vb][/vb] tags when you post your code.
Edit or reply to this post to see how.
Thank you.
|
Last edited by Timbo; 09-20-2005 at 02:31 PM.
|

09-20-2005, 01:40 PM
|
|
Freshman
|
|
Join Date: Sep 2005
Posts: 34
|
|
|
sorry guys, I forgot to mention the code I just posted actually contains other functions which reference a terminal screen, so you can't really test it yourself, which is why I put a comment where its getting the run-time error 13
|
|

09-20-2005, 02:36 PM
|
 |
Green-Eyed
Super Moderator * Guru *
|
|
Join Date: May 2001
Location: Bangkok, Thailand
Posts: 10,261
|
|
It's ok, I wanted to see the data type declarations you had used...
What are the values contained by the two variables when the error occurs?
|
|

09-20-2005, 03:02 PM
|
|
Freshman
|
|
Join Date: Sep 2005
Posts: 34
|
|
Quote:
|
Originally Posted by Timbo
It's ok, I wanted to see the data type declarations you had used...
What are the values contained by the two variables when the error occurs?
|
as far as I can tell they are both strings..
this is really strange, I've never had this problem before, I've been testing this _all_ day today, and no matter what I've gotten the run-time error 13
this is another version I tried
Code:
Function r_Is(Optional shortname, Optional ScreenArray) As Variant
Dim a As Variant, rslt As String, shortname2
If IsMissing(shortname) = True And IsMissing(ScreenArray) = False Then GoTo movingon
If IsMissing(shortname) = False And IsMissing(ScreenArray) = True Then GoTo movingon
If IsMissing(shortname) = True And IsMissing(ScreenArray) = True Then GoTo movingon
GoTo donefalse
movingon:
evaluate00:
If IsArray(ScreenArray) Then
a = ScreenArray
Else
a = xlr(1, 1, 24, 80)
End If
rslt = "False" 'default 'taking out default, boolean errors?
If r_Is_Blank(a) Then rslt = "blank"
If r_Is_CHIST00(a) Then rslt = "chist00"
If r_Is_CHIST01(a) Then rslt = "chist01"
If r_Is_CHIST02(a) Then rslt = "chist02"
If r_Is_CHIST02pf11(a) Then rslt = "chist02pf11"
If r_Is_CHIST03(a) Then rslt = "chist03"
If r_Is_CHIST04(a) Then rslt = "chist04"
If r_Is_CHIST05(a) Then rslt = "chist05"
If r_Is_CHIST05pf11(a) Then rslt = "chist05pf11"
If r_Is_CHIST06(a) Then rslt = "chist06"
If r_Is_CHIST07(a) Then rslt = "chist07"
If r_Is_clOVR00(a) Then rslt = "clovr00"
If r_Is_clOVR01(a) Then rslt = "clovr01"
If r_Is_clOVR02(a) Then rslt = "clovr02"
If r_Is_ITFI00(a) Then rslt = "itfi00"
If r_Is_XAofDF(a) Then rslt = "xaofdf"
'MsgBox IsMissing(shortname)
If IsMissing(shortname) = False Then
If StrComp(shortname, rslt, vbTextCompare) = 0 Then GoTo donetrue
GoTo evaluate00
End If
donetrue: 'defaulting
r_Is = rslt
GoTo donedone
donefalse:
r_Is = False
GoTo donedone
donedone:
End Function
|
|

09-20-2005, 03:08 PM
|
|
Freshman
|
|
Join Date: Sep 2005
Posts: 34
|
|
also
|
I should have mentioned, the run-time error 13 mismatch only occurs when I call this function from another function, it works fine if I run it from a procedure
|
|

09-20-2005, 03:12 PM
|
 |
Captain TJ
Forum Leader * Expert *
|
|
Join Date: Jun 2003
Location: England
Posts: 1,664
|
|
|
What line of code is calling the function?
TJ
|
|

09-20-2005, 03:18 PM
|
|
Freshman
|
|
Join Date: Sep 2005
Posts: 34
|
|
|
this right here
[vb]
r_Is "itfi00"
[vb/]
|
|

09-21-2005, 09:06 AM
|
 |
Green-Eyed
Super Moderator * Guru *
|
|
Join Date: May 2001
Location: Bangkok, Thailand
Posts: 10,261
|
|
|
The reason why I asked you to verify the contents of the two Variant type variables, is to check that the data types are comparable. Comparing a String with a Boolean will cause an error. You need to start using specific data types in your code.
|
|

09-21-2005, 11:33 AM
|
|
Freshman
|
|
Join Date: Sep 2005
Posts: 34
|
|
|
I believe that was the problem, in any manner, I recoded the whole function into 2 functions, and it works now, tnx for your help guys
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|