列表框中的'findstring' [英] 'findstring' in listbox
问题描述
您好。
有人可以告诉我这里可能做错了吗?
我正在使用代码(lboxRP是一个列表框) :
将newRPindex调整为整数
newRPindex = Me.lboxRP.FindString(RP)
Me.lboxRP.SetSelected(newRPindex ,True)
当最后一行执行时,我收到一条错误消息:
类型为''System.ArgumentOutOfRangeException'的未处理异常'发生了
in system.windows.forms.dll
附加信息:指定参数超出有效范围
价值。
如果我'鼠标悬停''我的代码,价值RP应该是它应该是的字符串,并且
确实存在列表框中的项目...
帮助!!
TIA
Amber
Hello.
Can someone tell me what I may be doing wrong here?
I''m using the code (lboxRP is a listbox):
Dim newRPindex As Integer
newRPindex = Me.lboxRP.FindString(RP)
Me.lboxRP.SetSelected(newRPindex, True)
When the last line executes, I get an error message:
An unhandled exception of type ''System.ArgumentOutOfRangeException'' occurred
in system.windows.forms.dll
Additional information: Specified argument was out of the range of valid
values.
If I ''mouse-over'' my code, the value RP is the string it should be, and it
does exist as an item in the listbox...
Help!!
TIA
Amber
推荐答案
休息一下:
Me.lboxRP.SetSelected(newRPindex,True)
现在是什么这是ne的价值鼠标悬停时的wRP指数?
使用SetSelected方法需要为0或更大。
琥珀色写道:
Put a break on the line:
Me.lboxRP.SetSelected(newRPindex, True)
Now what''s the value of newRPindex when you mouseover it?
It will need to be 0 or greater to use the SetSelected method.
"amber" wrote:
你好。
有人能告诉我这里我做错了什么吗?
我正在使用代码(lboxRP是一个列表框):
将newRPindex变为整数
newRPindex = Me.lboxRP.FindString(RP)
Me.lboxRP.SetSelected(newRPindex,True)
当最后一行执行时,我收到一条错误消息:
在system.windows.forms.dll中发生未处理的System.ArgumentOutOfRangeException类型异常
>
附加信息:指定的参数超出了有效值范围。
如果我'鼠标悬停''我的代码,值RP是字符串它应该是,并且它确实作为列表框中的项目存在...
帮助!!
TIA
Amber
Hello.
Can someone tell me what I may be doing wrong here?
I''m using the code (lboxRP is a listbox):
Dim newRPindex As Integer
newRPindex = Me.lboxRP.FindString(RP)
Me.lboxRP.SetSelected(newRPindex, True)
When the last line executes, I get an error message:
An unhandled exception of type ''System.ArgumentOutOfRangeException'' occurred
in system.windows.forms.dll
Additional information: Specified argument was out of the range of valid
values.
If I ''mouse-over'' my code, the value RP is the string it should be, and it
does exist as an item in the listbox...
Help!!
TIA
Amber
值为-1。
这就是问题 - 我正试图将它设置为等于指数
findstring返回。
TIA
Amber
The value is -1.
That''s the problem - I''m trying to set it to equal the index that the
findstring returns.
TIA
Amber
尝试将初始搜索位置设置为-1,
newRPindex = Me.lboxRP.FindString(RP ,-1)
你已经检查过RP没有前缀或带有空格后缀
(chr
Try setting the initial search location to -1,
newRPindex = Me.lboxRP.FindString(RP, -1)
You''ve checked that there''s RP is not prefixed or suffixed with spaces
(chr
这篇关于列表框中的'findstring'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!