Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a limit on the number of characters returned by a function? 1

Status
Not open for further replies.

FancyPrairie

Programmer
Oct 16, 2001
2,917
US
I have some code that has been working for a couple of years. However, today, one of the functions is not working correctly. Prior to exiting the function, I check the string the function is returning. It is what it is supposed to be. The variable that receives the value of the function is blank. For example:

Function abc()
abc = "blahblahblah"
End Function

....
Dim myValue as string

myValue = abc
...

Although abc returns "blah...", myValue = "".

I have decompiled my code and compacted and repaired the database. Because that didn't work, I'm assuming that there must be a limit on the number of characters a function can return. Is there? (Note I've searched the net (for a few minutes) but have not found where there is a limit.)
 
Yes the limit is 2^31 (2 billion) characters. I am taking a wild guess you did not hit it. "Not working properly" does not provide much information. Can you post the actual code, and better describe what is not functioning.
 
I appreciate your response. I thought that was the limit, but was grabbing at straws.

I don't think it would help to provide my code. Although the function is short, it calls other functions that return stuff.
But, as I explained in the previous post, prior to the function exiting, I check the string, via debug, that the function is returning and it looks fine in the Immediate window. But the value that receives the string is blank. I tried returning the 1st thousand characters and that works ok. I guess I need to check the string for some weird character that's causing the problem.

Thanks for verifying the limit for me.
 
As you described in your OP, your function returns Variant (since it does not have type declared). You just happened to assign String to it, and your Value is declared as String.

To test your situation, either change:
Function abc()
to
Function abc() As String

or change:
Dim myValue as string
to:
Dim myValue as Variant

and see if that will work.

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Good catch Andrzejek. But that was a mistake I made when posting it. I do declare the function as returning a string in my code.
 
If FancyPrairie calls:
[tt]
Dim myValue as string
myValue = abc[/tt]

And the code does not create an error, abc is a valid call that we assume is calling Funcrion abc.

Unless there is some other procedure/function also called [tt]abc[/tt] ? (Overloading?)

Stepping thru the code may halp to see where it is going and which part of code gets executed.

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
We know that the function is being called since the OP has stated that "prior to the function exiting, I check the string, via debug"

However, it is just possible that [tt]myValue[/tt] has a scope problem. Obviously, without seeing the code - which the OP feels is unnecessary - we are just guessing.
 
I think I found the problem. I've created a wizard that scans through the all of the controls on the form and stores their properties in a table. The wizard than, for each control, creates a web form element. When finished, I have a web form that looks just like the Access form. And it has most of the functionality of an Access form, including a split view. One problem I have is dealing with the Row Source of a combobox. That becomes a little complicated. Anyway, I created the Row Source via the query builder. Evidently, the query builder stuck some characters in there (carriage return (although that works elsewhere) or something). I got rid of the carriage returns and it now runs fine. I don't understand how that could have been a problem.

I guess it would be a real simple thing to test. Simply create a function that reads the Row Source and returns it to the caller. In my case, the caller received a blank string. Note that my wizard formats the string so that it represents a web form drop-down list box (sort of). The string I'm returning looks something like this:

Code:
		<!--**** lngEmpID ****-->
	<div   id="divlngEmpID" class="cboWrapper" style="left: 168px; top: 112px; width: 298px; height: 23px; "  data-inputTagId="txtlngEmpID"  >
		<div   id="div_txtlngEmpID" class="cboGroup"   style="left: 104px; top: 0px; width: 193px; height: 23px;  background-color: transparent;  color: #0000FF; border: 1px  solid #D9D8D8;font-size: 10pt; font-family: Arial; padding: 6px 2px 2px 2px;  background-color: transparent;" data-inputTagId="txtlngEmpID">
			<input  id="txtlngEmpID" class="cbo"    style=" left: 0; top: 0; width: 173px; height: 23px;  color: #0000FF; font-size: 10pt; font-family: Arial; padding: 6px 2px 2px 2px;  " datafld="lngEmpID"  data-alt="" data-DefaultValue="" type="text" size="~size~" maxlength="~maxlength~" title=""    tabIndex="1" />
			<input  id="btn_txtlngEmpID" class="cbo" name="btn_txtlngEmpID" tabindex="-1"   type="button" data-inputTagId="txtlngEmpID"/>
		</div>
		<label  id="lbllngEmpID" class="cbo"    style="left: 0px; top: 0px; width: 100px; height: 23px;  background-color: transparent; border: 1px  solid #D9D8D8;padding: 6px 2px 2px 2px; text-align: left ; " for="txtlngEmpID">Employee:</label>
		
		<div    id="cbolngEmpID" class="cboSQL" style=" left: 104px; height: 23px;  background-color: transparent; border: 1px  solid #D9D8D8;padding: 6px 2px 2px 2px; top: 33px; width: 192px;  " datafld="lngEmpID" data-alt="" data-inputTagId="txtlngEmpID" data-dataSheetCaption="divlngEmpID" data-value="" data-controlType="comboboxgrid" data-dataType="Long" data-dataType_DisplayColumn="text" data-Caption="(Select item...)" data-DefaultValue="null"  title=""
				data-displayWidth   = "192"
				data-rowSourceType  = "Table/Query"
				data-rowSource      = "SELECT tblEmployee.strFullName, tblEmployee.lngEmpID, tblEmployee.strOfficephone, tblEmployee.strOfficeNumber, tblEmployee.strEmail,  tblEmployee.lngDeptID, tblDept.strName, tblMMC_Facility.strAbbrev FROM  tblFacility RIGHT OUTER JOIN tblDept ON tblFacility.lngFacilityID = tblDept.lngFacilityID RIGHT OUTER JOIN tblEmployee ON tblDept.lngDeptID = tblEmployee.lngDeptID WHERE (tblEmployee.strFullName IS NOT NULL) ORDER BY tblEmployee.strFullName "
				data-autoDropDown   = "false"
				data-boundColumn    = "2"
				data-limitToList    = "limit=True;action=openform;Name=~strFormName~;TableName=~strTableName~"
				data-columnWidths   = "144;0;0;0;0;0;0;0"
				data-headings       = ""
				data-listRows       = "16"
				data-showMoreText   = "more"
				data-filterRecords  = "true"
				data-environment    = "Local"
				data-databaseId     = "Library">
		</div>
	</div>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top