首页 > 解决方案 > 从并行数组中获取值并在下一行插入新值

问题描述

https://i.stack.imgur.com/NTZa5.jpg

我在添加按钮中的代码

Dim item() As String = {"Hardisk", "Pen Drive", "Mouse", "Memory", "Keyboard"}
        Dim price() As Decimal = {200.0, 57.0, 45.0, 130.0, 58.0}
        Dim counter As Integer
        Dim items As String
        Dim quantity As String
        Dim findItem As String
        Dim find As Boolean = False

        lblOut.Text = "ITEM" & vbTab & "QTY" & vbTab & "PRICE" & vbTab & "SUBTOTAL" & vbNewLine

        items = txtItem.Text
        quantity = txtQuantity.Text
        findItem = items
        itemPrice = subtotal

        For counter = 0 To 4
            If findItem = lblOut.Text(counter) Then
                find = True
            End If
        Next

        lblOut.Text = lblOut.Text & items & vbTab & quantity & vbTab & itemPrice & vbTab & subtotal & vbNewLine
    End Sub

当我在项目框中输入我的项目时,它应该在价格数组中搜索价格并显示到价格和 * 的文本框区域以及数量。然后我可以为新行添加下一项。

我面临的问题是当我将商品插入商品区域时如何从商品中获取价格,系统检查代码中设置的值。

以及当我想在文本框中添加 now 值时如何转到下一行。

标签: vb.net

解决方案


推荐阅读