作者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/m.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