⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 16838.html

📁 VB技巧问答10000例 VB技巧问答10000例
💻 HTML
字号:
<html>
  <head>
    <title>Re: 如何利用for回圈来call子程式(sub)呢?</title>
  </head>
  <body bgcolor="#FFFFFF" vlink="#808080">
    <center>
      <h1>Re: 如何利用for回圈来call子程式(sub)呢?</h1>
    </center>
<hr size=7 width=75%>

<hr size=7 width=75%><p>
Posted by Sun Jack on August 07, 1999 at 08:22:34:<p>
In Reply to: <a href="16717.html">如何利用for回圈来call子程式(sub)呢?</a> posted by 小明 on August 05, 1999 at 20:31:39:<p>
: <br>: 若是有一大堆子程式名称都很接近<br>: 好比OpenTable1, OpenTable2, OpenTable3...<br>: 正常的做法就call OpenTable1, call OpenTable2...<br>: 不知道有没有更好的方法?<br>: 好比用for..next来控制call OpenTableXXX<br>:                                    ^^^<br>: 谢谢~<p>如果你要呼叫的副程式是 Object 的 Interface,则可以用<br>CallByName 的方式来呼叫.下面的例子为执行form1 的Interface 及 Class1 的 Interface<p>'*****************************<br>'Form1 的内容<br>Option Explicit<p>Private Sub Form_Load()<br>   Dim i As Long<br>   Dim obj As Class1<br>   <br>   For i = 1 To 3<br>      CallByName Me, "OpenTable" & i, VbMethod<br>   Next i<br>   <br>   <br>   Set obj = New Class1<br>   For i = 1 To 3<br>      CallByName obj, "OpenTable" & i, VbMethod<br>   Next i<br>   Set obj = Nothing<br>   <br>   <br>End Sub<p><br>Public Sub OpenTable1()<br>   MsgBox "Form1.OpenTable1"<br>End Sub<p><br>Public Function OpenTable2() As Boolean<br>   MsgBox "Form1.OpenTable2"<br>End Function<p><br>Public Function OpenTable3() As String<br>   MsgBox "Form1.OpenTable3"<br>End Function<p><p>'**************************<br>'Class1 的内容<p>Option Explicit<p>Public Sub OpenTable1()<br>   MsgBox "Class1.OpenTable1"<br>End Sub<p><br>Public Function OpenTable2() As Boolean<br>   MsgBox "Class1.OpenTable2"<br>End Function<p><br>Public Function OpenTable3() As String<br>   MsgBox "Class1.OpenTable3"<br>End Function<br>
<br>
<br><hr size=7 width=75%><p>
<a name="followups">Follow Ups:</a><br>
<ul><!--insert: 16838-->
</ul><!--end: 16838-->
<br><hr size=7 width=75%><p>

</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -