【问题标题】:I'm trying to pull a value from an array but it's only pulling the first value and I'm not sure why?我试图从数组中提取一个值,但它只是提取第一个值,我不知道为什么?
【发布时间】:2017-09-30 04:31:04
【问题描述】:

我将 Autodesk Inventor 与 Visual Basic 结合使用,并尝试在框中显示一个值。值都显示,除了一个。值 fractionDisplay(thicknessDisplay) 一直在框中显示 3/16(这是我的 fractionDisplay() 数组中的第一个值)。为什么不显示基于厚度显示数字设置为0以外的其他值?

这是我的代码:

Dim erpNumber() As String = {"PA0001", "PA0002", "PA0003", "PA0004", "PA0006", "PC0003", "PC0004", "PC0005", "PC0006", "PC0007", "PC0008", "PC0009", "PC0010", "PC0011"}
Dim fractionDisplay() As String = {"3/16", "1/4", "5/16", "3/8", "1/8", "1/2", "5/8", "3/4", "1", "1 1/4", "1 1/2", "2", "2 1/2", "3"}

stockNumberValue = erpNumber(plateThickness)

iProperties.Value("Project", "Description") = fractionDisplay(thicknessDisplay) & """" & " X " & Length & """" & " X " & Width & """" & " 100XF BURNOUT"

If Thickness = 0.1875 Then
    plateThickness = 0
    thicknessDisplay = 0
ElseIf Thickness = 0.25 Then
    plateThickness = 1
    thicknessDisplay = 1
ElseIf Thickness = 0.3125 Then
    plateThickness = 2
    thicknessDisplay = 2
ElseIf Thickness = 0.375 Then
    plateThickness = 3
    thicknessDisplay = 3
ElseIf Thickness = 0.125 Then
    plateThickness = 4
    thicknessDisplay = 4
ElseIf Thickness = 0.5 Then
    plateThickness = 5
    thicknessDisplay = 5
ElseIf Thickness = 0.625 Then
    plateThickness = 6
    thicknessDisplay = 6
ElseIf Thickness = 0.75 Then
    plateThickness = 7
    thicknessDisplay = 7
ElseIf Thickness = 1 Then
    plateThickness = 8
    thicknessDisplay = 8
ElseIf Thickness = 1.25 Then
    plateThickness = 9
    thicknessDisplay = 9
ElseIf Thickness = 1.5 Then
    plateThickness = 10
    thicknessDisplay = 10
ElseIf Thickness = 2 Then
    plateThickness = 11
    thicknessDisplay = 11
ElseIf Thickness = 2.5 Then
    plateThickness = 12
    thicknessDisplay = 12
ElseIf Thickness = 3 Then
    plateThickness = 13
    thicknessDisplay = 13
End If

stockNumberValue = erpNumber(plateThickness)
iProperties.Value("Project", "Stock Number") = stockNumberValue

如果用户输入 0.5,我会得到以下结果:

库存编号:PC0003

描述:3/16" X 12" X 5" 100XF BURNOUT

应该说 1/2" X 12" X 5" 100XF BURNOUT

【问题讨论】:

  • 在您读取数组时,您尚未设置厚度显示。 iProperties.Value("Project", "Description") = ..... 需要在 If 之后
  • @OldBoyCoder 谢谢!就是这样。我在想这与代码的顺序有关,但我只是看不到它。再次感谢您

标签: vb.net autodesk-inventor


【解决方案1】:

在您读取数组时,您尚未设置厚度显示。

iProperties.Value("Project", "Description") = fractionDisplay(thicknessDisplay) & """" & " X " & Length & """" & " X " & Width & """" & " 100XF BURNOUT"

需要在Ifs和Elseifs集合之后

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多