作者o1o3o1o31030 (主席)
看板Visual_Basic
标题[VBA ] ByRef引数传递错误
时间Mon Apr 10 10:06:42 2023
用VBA制作了一个UserForm,用来键入参数
键入後按确认传递给SUB
但是一直出现ByRef引数型态不符
请版大救救我
------------------------------------------------------
Private Sub BT1_Click()
Dim P, S, D As Integer
If CBB1 = "上" Then
P = 1
ElseIf CBB1 = "下" Then
P = 8
End If
If CBB2 = "左" Then
S = 1
ElseIf CBB2 = "右" Then
S = 0
End If
If CBB3 = "前" Then
D = 1
ElseIf CBB3 = "後" Then
D = 0
End If
Call 测试(P, S, D) ------------------->这里出现ByRef 引数型态不符
Unload UF1
End Sub
-------------------------------------------------------
Public Sub 测试(P As Integer, S As Integer, D As Integer)
msgbox P & S & D
End Sub
-----------------------------------------------------------
谢谢各位
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 1.163.121.90 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Visual_Basic/M.1681092404.A.7F3.html
※ 编辑: o1o3o1o31030 (1.163.121.90 台湾), 04/10/2023 10:08:25
※ 编辑: o1o3o1o31030 (1.163.121.90 台湾), 04/10/2023 10:13:17
1F:→ lalacos123: Call 测试(int(P), int(S), int(D)) ? 04/10 12:34
2F:→ MOONRAKER: 应该是dim p as integer, s as integer, d as integer 04/10 16:30
3F:→ MOONRAKER: VB6的type并不好用 你刚开始写就写as variant即可 04/10 16:32
4F:→ MOONRAKER: 以免浪费时间 04/10 16:33
5F:→ ShoterMan: 同二楼 逐一定义 04/17 09:09