Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > function question


Reply
 
Thread Tools Display Modes
  #1  
Old 09-20-2005, 08:14 AM
rjokay rjokay is offline
Freshman
 
Join Date: Sep 2005
Posts: 34
Default 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
Reply With Quote
  #2  
Old 09-20-2005, 09:18 AM
Sarackganda's Avatar
Sarackganda Sarackganda is offline
Regular
 
Join Date: Mar 2004
Location: Buenos Aires, Argentina
Posts: 56
Default

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!
Reply With Quote
  #3  
Old 09-20-2005, 10:16 AM
rjokay rjokay is offline
Freshman
 
Join Date: Sep 2005
Posts: 34
Default

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
Reply With Quote
  #4  
Old 09-20-2005, 10:23 AM
Timbo's Avatar
Timbo Timbo is offline
Green-Eyed

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Bangkok, Thailand
Posts: 10,261
Default

Post the full procedure and we'll take a look.
__________________
"He's not the Messiah. He's a very naughty boy!" - Brian's mum

Can't find the answer? >> Try something new!
Become a Professional
Reply With Quote
  #5  
Old 09-20-2005, 01:36 PM
rjokay rjokay is offline
Freshman
 
Join Date: Sep 2005
Posts: 34
Default

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.
Reply With Quote
  #6  
Old 09-20-2005, 01:40 PM
rjokay rjokay is offline
Freshman
 
Join Date: Sep 2005
Posts: 34
Default

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
Reply With Quote
  #7  
Old 09-20-2005, 02:36 PM
Timbo's Avatar
Timbo Timbo is offline
Green-Eyed

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Bangkok, Thailand
Posts: 10,261
Default

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?
__________________
"He's not the Messiah. He's a very naughty boy!" - Brian's mum

Can't find the answer? >> Try something new!
Become a Professional
Reply With Quote
  #8  
Old 09-20-2005, 03:02 PM
rjokay rjokay is offline
Freshman
 
Join Date: Sep 2005
Posts: 34
Default

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
Reply With Quote
  #9  
Old 09-20-2005, 03:08 PM
rjokay rjokay is offline
Freshman
 
Join Date: Sep 2005
Posts: 34
Default 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
Reply With Quote
  #10  
Old 09-20-2005, 03:12 PM
tinyjack's Avatar
tinyjack tinyjack is offline
Captain TJ

Forum Leader
* Expert *
 
Join Date: Jun 2003
Location: England
Posts: 1,664
Default

What line of code is calling the function?

TJ
__________________
Oh dear, I need a beer.
Online Motorsport Game
Reply With Quote
  #11  
Old 09-20-2005, 03:18 PM
rjokay rjokay is offline
Freshman
 
Join Date: Sep 2005
Posts: 34
Default

this right here
[vb]
r_Is "itfi00"
[vb/]
Reply With Quote
  #12  
Old 09-21-2005, 09:06 AM
Timbo's Avatar
Timbo Timbo is offline
Green-Eyed

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Bangkok, Thailand
Posts: 10,261
Default

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.
__________________
"He's not the Messiah. He's a very naughty boy!" - Brian's mum

Can't find the answer? >> Try something new!
Become a Professional
Reply With Quote
  #13  
Old 09-21-2005, 11:33 AM
rjokay rjokay is offline
Freshman
 
Join Date: Sep 2005
Posts: 34
Default

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
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->