【问题标题】:vb.net option strict disallows late binding when trying to add to array cant turn off尝试添加到数组时,vb.net 选项严格禁止后期绑定无法关闭
【发布时间】:2015-11-11 22:38:24
【问题描述】:

我正在尝试使用数组中的项目构建组合框,但出现此错误:

这是我的代码:

Private Sub frmInventory_Load(sender As Object, e As EventArgs) Handles Me.Load
    Dim InvArray As Array
    InvArray = Inventory.BuildInvArray()
    Option Strict Off
    For i As Integer = 0 To 5
        cmbSystem.Items.Add(InvArray(i,1))
    Next
End Sub

【问题讨论】:

  • 那不是有效的代码。 Option Strict 是位于模块顶部的指令。你不能在事件或方法的中间关闭它

标签: arrays vb.net option-strict


【解决方案1】:

可以使用Array.GetValue来完成

Private Sub frmInventory_Load(sender As Object, e As EventArgs) Handles Me.Load
    Dim InvArray As Array
    InvArray = Inventory.BuildInvArray()
    For i As Integer = 0 To 5
        cmbSystem.Items.Add(InvArray.GetValue(i, 1))
    Next
End Sub

【讨论】:

  • 这看起来像是对您的原始问题的失败编辑。删除它,因为它只会混淆其他人。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-31
  • 1970-01-01
  • 2022-06-22
  • 2021-02-08
  • 2021-11-27
相关资源
最近更新 更多