VB6 CallByName 问题
我想为一些 Subs 执行 CallByName,但我就是无法让它运行。
一切都很顺利,直到执行到达 CallByName
,然后我遇到问题:
- 每当我使用
Me
时,它都会抱怨编译错误 - 如果我使用
frmMyServer
>,它说“不支持对象或方法”
问题:我该怎么做?
这就是我所拥有的:
在我的“modHandleData”中,
Private Sub HandleRequestScriptedNPC(...)
' ...
NPCMethod = "Scripted_Npc_" & NpcNum
CallByName Me, NPCMethod, VbMethod, NpcNum, Index
End Sub
在“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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在模块中调用代码,因此不存在
Me
实例(仅存在于类中,包括表单)。我的 VB6 有点生疏,但我相信您不能使用CallByName
调用模块中的方法,因为您需要一个对象。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 usingCallByName
since you need an object.