变量类型长期没有收到价值?

时间:2014-05-05 13:20:02

标签: excel vba excel-vba

所以,我试图获得一段代码来基于变量输入设置一些轴值,我认为这是非常容易的,但是......在下面的代码中,变量iFlatMax只等于零,而不是我在If语句中告诉它的值。是什么赋予了? iCamType设置在另一个Sub()

Private Sub PlotResults()

Dim wbNew As Workbook
Dim iRegSamples As Long
Dim iColumnStart As Long
Dim sXValues As String
Dim sYValues As String
Dim iToeMin, iToeMax, iFlatMin, iFlatMax As Long

'Set axes values based on cam type
If iCamType = 93 Then
    iToeMin = -0.02
    iToeMax = 0
    iFlatMin = -0.015
    iFlatMax = 0.025
Else
    iToeMin = -0.01
    iToeMax = 0.01
    iFlatMin = -0.01
    iFlatMax = 0.015
End If

'More code

End Sub

1 个答案:

答案 0 :(得分:3)

变化:

Dim iToeMin, iToeMax, iFlatMin, iFlatMax As Long

为:

Dim iToeMin as Double, iToeMax as Double, iFlatMin as Double, iFlatMax As Double