【问题标题】:How can I delete an item from a list using CInt and Split in VB.net如何在 VB.net 中使用 CInt 和 Split 从列表中删除项目
【发布时间】:2012-10-26 20:24:34
【问题描述】:

我想从列表和数据库中删除一个项目。这是我使用的代码:

Dim nr As Integer
        Dim s As String
        s = lstPatiënten.ToString
        nr = CInt(s.Split("-"c)(0))
        For Each d In patienten
            If d.nr = nr Then
                If patientenDB.PatientVerwijderen(d) > 0 Then
                    initGetPatienten()
                End If
            End If
        Next

但它不起作用..错误是:

从字符串“System.Windows.Forms.ListBox, It”转换为类型 “整数”无效。

但是当我输入 Nr = 83(83 是我的患者的用户 ID)时,它起作用了。

有人可以帮帮我吗?

【问题讨论】:

    标签: vb.net string list split int


    【解决方案1】:

    您需要将s = lstPatiënten.ToString 更改为s = lstPatiënten.SelectedItem.ToString。试一试,让我知道它是否有效。

    Listbox.SelectedItem

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-27
      • 2012-08-23
      • 1970-01-01
      • 2021-07-19
      • 2016-03-12
      • 1970-01-01
      相关资源
      最近更新 更多