处理Split()函数:如何针对返回/制表符输入进行调整 [英] Dealing with Split() function: how to adjust for either return/tab input
问题描述
我目前有一个正在使用的序列号清单数据库.我当时使用带有空格定界符的split()函数将数据分成单独的数据点,但是我使用的扫描仪使用'return'或'tab'的定界符
在split()函数中是否可以使用这些函数中的任何一个?
我不相信制表符是可行的,因为制表符会跳到下一个"按钮...因此,当扫描仪在文本框中输入例如(data1 [tab] data2 [tab] data3 [tab])时,我的输出简直就是"data1" ...我相信是因为然后访问利用了选项卡"按钮,只是从我的文本框移到了下一个项目.实际上,它甚至不会显示任何超过第一组的数据,因为它会看到制表符并继续前进.有什么办法改变吗?
第二,我可以将扫描仪更改为输入return或Enter键作为扫描仪定界符,从而创建:
数据1 数据2 data3
在我的文本框中.
有什么方法可以更改提供的代码以分析文本框的行并以这种方式存储信息(也许...将每行设置为i,然后运行以下代码.
我希望这是有道理的!我当前用于空间定界符数据的代码是:
Dim InputString() As String
Dim i As Integer
InputString = Split(InputName, " ")
For i = 0 To UBound(InputString)
CurrentDb.Execute "INSERT INTO InventoryInputT(InputID) VALUES ('" & InputString(i) & "')"
Next i
我无法理解您的问题,因为标签中的标签与其他任何字符都相同. >
但是,如果您要问的是如何拆分包含制表符(即Chr(9)
s)作为分隔符的字符串,则可以使用
InputString = Split(InputName, vbTab) ' to split on Chr(9)
对于返回"字符,您可以使用以下之一,具体取决于它是哪种返回"字符
InputString = Split(InputName, vbCr) ' to split on Chr(13)
InputString = Split(InputName, vbLf) ' to split on Chr(10)
InputString = Split(InputName, vbCrLf) ' to split on Chr(13)&Chr(10)
很显然,如果您愿意,也可以使用实际的Chr(x)
代替各种常量.
I currently have a serial number inventory database I am working on. I was using the split() function with a space delimiter to separate the data into individual data points, however the scanner I use uses delimiters of either 'return' or 'tab'
Is there any way to use either of those functions in the split() function??
I don't believe tab is possible because tab jumps to the 'next' button... so when the scanner inputs for example (data1 [tab] data2 [tab] data3 [tab]) into the textbox, my output is simply "data1"... I believe because then access utilizes the 'tab' button and just moves from my textbox to the next item. Effectively, it won't even display any data past the first set because it sees tab and moves on. Any way to change this?
Secondly, I can change the scanner to input return or the enter key as scanners delimiters, creating:
data1 data2 data3
in my text box.
Is there any way I can alter the provided code to analyze the lines of the text box and store the information that way (maybe... set each line to i and then run the below code.
I hope this makes sense! My current code that worked for space delimiter data was:
Dim InputString() As String
Dim i As Integer
InputString = Split(InputName, " ")
For i = 0 To UBound(InputString)
CurrentDb.Execute "INSERT INTO InventoryInputT(InputID) VALUES ('" & InputString(i) & "')"
Next i
I couldn't understand your question's comments about tabs moving to the next button, because a tab within a string is just the same as any other character.
However, if what you are asking is how to split a string containing tabs (i.e. Chr(9)
s) as delimiters, you can use
InputString = Split(InputName, vbTab) ' to split on Chr(9)
For "return" characters, you can use one of the following, depending on what sort of "return" character it is
InputString = Split(InputName, vbCr) ' to split on Chr(13)
InputString = Split(InputName, vbLf) ' to split on Chr(10)
InputString = Split(InputName, vbCrLf) ' to split on Chr(13)&Chr(10)
Obviously, you could also use the actual Chr(x)
instead of the various constants if you wanted to.
这篇关于处理Split()函数:如何针对返回/制表符输入进行调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!