VB 6列表视图SUBSTRING_INDEX [英] Vb 6 listview substring_index
问题描述
我在包含列ID VB6一个列表视图,ID的值是PID-id其中id是在我的数据库等于ID。防爆。 PID-56,PID-57。我想要的是当我得到列id的值,在我的列表视图第一个值,假设PID-56,我只想ID部等于56。
I have a listview in vb6 containing the column ID, the values of ID are PID-id where id is equal to id in my database. Ex. PID-56, PID-57. What i want is when i get the value of column id, first value in my listview , let's say PID-56, I only want the ID part which is equal to 56.
防爆。
value=.text --> PID-56
newvalue=56 --> PID- is not included so 56 now can be a integer.
我怎样才能除去'PID-考虑到我在VB6中使用的ListView。
How can i remove the 'PID-' considering I am using LIstview in vb6.
建议立即进行删除我使用什么功能?
What function shoul i be using?
推荐答案
如果您知道该字符串的总是的开头 PID -
和格式不会的曾经的变化,那么你可以使用的基本字符串操作功能之一。在这种情况下,你可能要配对的与
功能。在莱恩右
函数莱恩
函数将返回字符串的长度(字符的总数,它包含),以及右
函数将返回指定长度的字符串,从整个字符串的右侧开始。
If you know that the string always starts with PID-
and that format won't ever change, then you can use one of the Basic string manipulation functions. In this case, you probably want to pair the Right
function with the Len
function. The Len
function will return the length of the string (the total number of characters that it contains), and the Right
function will return the substring of the specified length, starting from the right side of the whole string.
最后,您需要使用标准值的转换之一,该字符串值转换成数值。在这种情况下,自然地,你想要的 CINT
运营商。
Finally, you'll need to use one of the standard value conversions to convert that string value into a numeric value. In this case, naturally, you want the CInt
operator.
例如:
Private Function ExtractIDFromString(ByRef str As String) As Integer
Const prefixLength As Long = 4 ' length of the "PID-" prefix
Dim strID As String
strID = Right$(str, Len(str) - prefixLength)
Return CInt(strID)
End Function
这篇关于VB 6列表视图SUBSTRING_INDEX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!