rlb.usa
rlb.usa

Reputation: 15043

VB6 CallByName woes

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:

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

Upvotes: 0

Views: 1685

Answers (1)

Konrad Rudolph
Konrad Rudolph

Reputation: 545638

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.

Upvotes: 4

Related Questions