中等functionExcel正在从用户窗体的文本中跳过0
Private Sub Submit_Click() Dim ndc, qty As String ndc = "'" & TextBox1.Value qty = TextBox2.Text ndc = Right(ndc, TextBox1.TextLength - 1) ndc = Left(ndc, TextBox1.TextLength - 2)
以上代码用于validation在数字的前面和后面用“/”读入的UPC数据。 数字也可以是不同的长度,这里是一个示例:
\357237031056\ \354838555509\ \001798022021\
这是我的结果:
357237031056 354838555509 1798022021
所以最后一个入口就是乱七八糟的地方,是什么给了? 我使用“'”将其格式化为文本,而且我也尝试过使用.Text,但仍然出现同样的问题。
忽略我的评论 – 如果你将ndc
声明为String,那么下面代码的结果不会改变(尽pipe如果这是你想要的types,你应该这样做)
使用input值\001798022021\
–
Private Sub Tester() Dim ndc, qty As String ndc = "'" & TextBox1.Value ndc = Right(ndc, TextBox1.TextLength - 1) ndc = Left(ndc, TextBox1.TextLength - 2) Debug.Print ndc ' 001798022021 Range("A1").Value = ndc ' 1798022021 Range("A2").NumberFormat = "@" Range("A2").Value = ndc ' 001798022021 End Sub