coco86 0 Light Poster

Please help me!!! i've done somecode but it doesnt seems to match... error Out of stack space..

Public Function isEmpty()
Dim MyVar As String, MyCheck As String

MyCheck = isEmpty(MyVar) ' Returns True.

MyVar = Null ' Assign Null.
MyCheck = isEmpty(MyVar) ' Returns False.

MyVar = Empty ' Assign Empty.
MyCheck = isEmpty(MyVar) ' Returns True.
End Function

Do While Not ts.AtEndOfStream
d = ts.ReadLine
Call tracingFNDat(Mystring)

'function '
If isEmpty(Mfgno) Then
lbl1.Caption = "Error"

Else
lbl1.Caption = "NoError"

End If

Dani AI

Generated

The "Out of stack space" message usually means a routine is calling itself repeatedly (infinite recursion) or creating very deep call chains. In this thread appears to be using a custom empty-check routine in ways that can call it back again or mismatch its signature. Two practical fixes: stop shadowing built-in tests and make the check a simple, non-recursive helper that accepts the value to examine.

A robust helper for classic VB/VBA is to accept a Variant and test for Null first, then treat any non-null value as a string for length checks. For example:

Function IsNullOrEmpty(ByVal v As Variant) As Boolean
  If IsNull(v) Then
    IsNullOrEmpty = True
  Else
    IsNullOrEmpty = (Len(Trim$(CStr(v))) = 0)
  End If
End Function

Debugging tips: set a breakpoint inside the helper and Step Into to see whether the routine re-enters itself; use the call stack to find repeated frames. Verify loop variables match the argument you pass to your tracing routine (a read/assign using one variable but calling the tracer with a different name is a common slip). Prefer the built-in checks where appropriate (VBA has IsNull and IsEmpty; VB.NET has String.IsNullOrEmpty) — see Microsoft documentation for details: IsNull (VBA), IsEmpty (VBA), and String.IsNullOrEmpty (.NET).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.