我有一个工具,我设计用于在一组用户表单中向用户提出一些问题。表单将通过将userform的整数结果传递给main sub来生成分数,main sub将代码传递给工作表。我的问题是主模块没有获取从私有模块传递的值,这里发生了什么?
我首先尝试使用未通过的布尔值来执行此操作,现在我尝试使用也不通过的整数结果来执行此操作。
用户表格代码:
Private Sub Image1_Click()
Select Case MsgBox("You have picked Thinks Commercially, is this correct?", vbYesNo, "Please Confirm")
Case VbMsgBoxResult.vbYes
Call Main.CountResults(ThinksCommerciallyInt = 1, OptimisesTalentInt = 0, DeliversPIInt = 0, DrivesExecutionInt = 0, ChampionsChangeInt = 0, OperatesColInt = 0)
UserForm1.Hide
UserForm2.Show
Case VbMsgBoxResult.vbNo
MsgBox ("Please Select Again")
End Select
End Sub
主要子代码
Public Sub CountResults(ThinksCommerciallyInt As Integer, OptimisesTalentInt As Integer, DeliversPIInt As Integer, DrivesExecutionInt As Integer, ChampionsChangeInt As Integer, OperatesColInt As Integer)
If ThinksCommerciallyInt = 1 Then
ThisWorkbook.Worksheets("Config").Range("B2").Value = ThinksCommerciallyInt
ThinksCommerciallyInt = ThinksCommerciallyInt + 1
ThinksCommerciallyInt = ThisWorkbook.Worksheets("Config").Range("B2").Value
End If
If OptimisesTalentInt = 1 Then
ThisWorkbook.Worksheets("Config").Range("B3").Value = OptimisesTalentInt
OptimisesTalentInt = OptimisesTalentInt + 1
OptimisesTalentInt = ThisWorkbook.Worksheets("Config").Range("B3").Value
End If
If DeliversPIInt = 1 Then
ThisWorkbook.Worksheets("Config").Range("B4").Value = DeliversPIInt
DeliversPIInt = DeliversPIInt + 1
DeliversPIInt = ThisWorkbook.Worksheets("Config").Range("B4").Value
End If
If DrivesExecutionInt = 1 Then
ThisWorkbook.Worksheets("Config").Range("B5").Value = DrivesExecutionInt
DrivesExecutionInt = DrivesExecutionInt + 1
DrivesExecutionInt = ThisWorkbook.Worksheets("Config").Range("B5").Value
End If
If ChampionsChangeInt = 1 Then
ThisWorkbook.Worksheets("Config").Range("B6").Value = ChampionsChangeInt
ChampionsChangeInt = ChampionsChangeInt + 1
ChampionsChangeInt = ThisWorkbook.Worksheets("Config").Range("B6").Value
End If
If OperatesColInt = 1 Then
ThisWorkbook.Worksheets("Config").Range("B7").Value = OperatesColInt
OperatesColInt = OperatesColInt + 1
OperatesColInt = ThisWorkbook.Worksheets("Config").Range("B7").Value
End If
End Sub
答案 0 :(得分:2)
在您的主叫代码中:
ThinksCommerciallyInt = 1
应该是
ThinksCommerciallyInt := 1
类似于其他参数