Android Question [SOLVED]Strange thing in CallSub

incendio

Well-Known Member
Licensed User
Longtime User
I was testing AutoTextSize Class, and tried to create my own EditText Class.

Something strange with sub CallSub.

Here are my code in main Activity
B4X:
Sub Process_Globals
End Sub

Sub Globals
    Dim edt1 As CustomEdT
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    edt1.Init(Me,"EnterPressed",0,2)
End Sub

Sub EnterPressed
    Msgbox("done","")
End Sub

and here are the snippet codes of my class
B4X:
Public Sub Init(Target As Object,EventName As String,FldTyp As Byte,DecimalNo As Byte)
   mTarget  = Target
   mEventName = EventName
   FieldType  = FldTyp
   DecNo     = DecimalNo 
   FormatField
End Sub

Private Sub edt_EnterPressed
    If SubExists(mTarget,mEventName.Trim) Then
        CallSub(mTarget,mEventName.Trim)
    Else
        Msgbox("Sub Not exist","")
    End If
End Sub

Those snippet code raised a message box that says Sub Not Exist, but if code in sub EnterPressed change to this
B4X:
Private Sub edt_EnterPressed
    If SubExists(mTarget,mEventName.Trim) Then
        CallSub(mTarget,"EnterPressed")
    Else
        Msgbox("Sub Not exist","")
    End If
End Sub

It return message box done, which is the correct one.
I wonder what is wrong here, am i missing something?

EDIT
changes in class code seem solved the problem.
 

Attachments

  • CallSub.zip
    9.4 KB · Views: 138
Last edited:
Top