gpt4 book ai didi

vb.net - 条码解析

转载 作者:行者123 更新时间:2023-12-04 05:13:43 30 4
gpt4 key购买 nike

例如我有这个表格:

如您所见,我有 Barcode 文本框,还有 6 个文本框。我需要的是一个代码,它将从文本框中解析我的条形码并填写剩余的字段。括号即 () ,以及里面的数字,必须删除。

LINK TO IMAGE

这是我的条形码示例

(1)CODE1(3)NAME(4)SURNAME(8)CODE2(10)CODE3(12)CODE4

现在我有这个代码:
Private Sub Barcode_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Barcode.Leave
Dim Duzina As String = Me.Barcode.Text.Length
Dim I As Integer = 0
Dim Slog As String = ""
Dim Rec As String = Me.Barcode.Text
For I = 4 To Duzina
If Rec.Substring(I, 1) = "(" Then
Me.Surname.Text = Slog
Exit For
End If
Slog = Slog + Rec.Substring(I, 0)
Next

End Sub

因此,当条码加载到第一个文本框时,它应该填满所有其他文本框。

最佳答案

我的简单解决方案

Private Sub Barcode_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Barcode.Leave
Dim codes = barcodeTextBox.Text.Split("("c)
Dim code1 = codes(1).Split(")"c)
Dim name = codes(2).Split(")"c)
Dim surename = codes(3).Split(")"c)
Dim code2 = codes(4).Split(")"c)
Dim code3 = codes(5).Split(")"c)
Dim code4 = codes(6).Split(")"c)

sureNameTextBox.Text = surename(0).ToString()
nameTextBox.Text = name(0).ToString()
code1TextBox.Text = code1(0).ToString()
code2TextBox.Text = code2(0).ToString()
code3TextBox.Text = code3(0).ToString()
code4TextBox.Text = code4(0).ToString()
End Sub

替代方案
Private Sub Barcode_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Barcode.Leave
Dim codes = barcodeTextBox.Text.Split("("c)
Dim code1 = codes(1).Split(")"c).FirstOrDefault()
Dim name = codes(2).Split(")"c).FirstOrDefault()
Dim surename = codes(3).Split(")"c).FirstOrDefault()
Dim code2 = codes(4).Split(")"c).FirstOrDefault()
Dim code3 = codes(5).Split(")"c).FirstOrDefault()
Dim code4 = codes(6).Split(")"c).FirstOrDefault()

sureNameTextBox.Text = surename
nameTextBox.Text = name
code1TextBox.Text = code1
code2TextBox.Text = code2
code3TextBox.Text = code3
code4TextBox.Text = code4
End Sub

关于vb.net - 条码解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14560498/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com