Question

I want to do a CallByName for some Subs but I just can't get it to go.

Everything goes fine until execution reaches the CallByName, then I have problems:

  • Whenever I use Me, it complains about a compile error
  • And if I use frmMyServer, it says "object or method not supported"

Question: How do I do this?

This is what I have :

in my 'modHandleData'

Private Sub HandleRequestScriptedNPC(...)
    ' ...
    NPCMethod = "Scripted_Npc_" & NpcNum
    CallByName Me, NPCMethod, VbMethod, NpcNum, Index
End Sub

in my 'modScriptedNPC'

Public Sub Scripted_Npc_9(ByVal NpcNum As Long, PlayerNum As Long)
    SendOneOptionMsg PlayerNum, "NPC 9", "NPC 9 talks." & vbCrLf & "Then gives you a clue"

End Sub
Was it helpful?

Solution

You’re calling the code in a module, so there is no Me instance (that only exists in classes, including forms). My VB6 is a bit rusty, but I believe you cannot call methods in modules using CallByName since you need an object.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top