如何将此字符串修复为长错误? [英] How to fix this String to Long Error??

查看:59
本文介绍了如何将此字符串修复为长错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误选项严格禁止隐式转换

从字符串到长


我得到这个代码


iStartPosition = InStr(iStartPosition + 1,RichTextBox1.Text," A" Or

" a"


the" &和a用蓝色加下划线。我该如何解决这个问题?


说我希望它是:

iStartPosition = InStr(iStartPosition + 1,RichTextBox1.Text,A或

" a"或U或u等


我怎么能让这个工作吗?

解决方案

Ron写道:


我是得到错误选项严格禁止隐式转换

从字符串到长


我得到这个代码


iStartPosition = InStr(iStartPosition + 1,RichTextBox1.Text," A"或

" a"


A和a用蓝色下划线。我该如何解决这个问题?


说我希望它是:

iStartPosition = InStr(iStartPosition + 1,RichTextBox1.Text,A或Or

" a"或U或u等


我该怎样才能完成这项工作?



您收到该错误消息,因为您在两个

字符串上使用Or运算符。由于运算符未定义为字符串,因此它会尝试查找

最接近的数据类型匹配。最接近的匹配是长的,但

没有从字符串到长的自动转换。


你可以使用IndexOfAny方法查找许多字符之一:


startPosition = RichTextBox1.Text.IndexOfAny(New Char(){" A" c," a" c,

Uc,uc})


-

G?跑Andersson

_____
http://www.guffa.com


Ron写道:


我收到错误选项严格禁止隐式转换

从字符串到长


我得到这个代码


iStartPosition = InStr(iStartPosition + 1,RichTextBox1.Text," A"或者

" a"


A和a用蓝色下划线。我该如何解决这个问题?


说我希望它是:

iStartPosition = InStr(iStartPosition + 1,RichTextBox1.Text,A或Or

" a"或U或u等


我该怎样才能完成这项工作?



你好罗恩,我以为你会回到最初的

线程(??),但无论如何,要实现你要求的只是改变

行到以下内容 -


iStartPosition = InStr(iStartPosition + 1,RichTextBox1.Text," AU-",

CompareMethod.Text)


注意,我添加的所有内容都是CompareMethod.Text

ShaneO


有10种人 - 那些了解Binary和那些

的人不会。


G?ran Andersson写道:


>

您可以使用IndexOfAny方法查找众多字符之一rs:


startPosition = RichTextBox1.Text.IndexOfAny(New Char(){" A" c," a" c,

" U" ; c,uc})



G?ran,Ron在这里有点困惑。他实际上试图找到所有出现的AU-,au-,Au-。或aU-。如果他发现任何一个'或'U',他也会找到A'和'你在他的文字的其他方面,

并不是他原先声称他想要的。


请看他原来的帖子 - " ;我该怎么做?

ShaneO


有10种人 - 那些了解二元和那些
$的人b $ b不要。


I am getting an error Option strict on disallows implicit conversion
from string to long

I get it for this code

iStartPosition = InStr(iStartPosition + 1, RichTextBox1.Text, "A" Or
"a"

the "A" and "a" are underlined in blue. How can I fix this?

Say I want it to be:
iStartPosition = InStr(iStartPosition + 1, RichTextBox1.Text, "A" Or
"a" Or "U" or "u" etc

how can I make this work?

解决方案

Ron wrote:

I am getting an error Option strict on disallows implicit conversion
from string to long

I get it for this code

iStartPosition = InStr(iStartPosition + 1, RichTextBox1.Text, "A" Or
"a"

the "A" and "a" are underlined in blue. How can I fix this?

Say I want it to be:
iStartPosition = InStr(iStartPosition + 1, RichTextBox1.Text, "A" Or
"a" Or "U" or "u" etc

how can I make this work?

You get that error message because you are using the Or operator on two
strings. As the operator is not defined for strings, it tries to find
the closest match for the data types. The closest match is long, but
there is no automatic conversion from string to long.

You can use the IndexOfAny method to find one of many characters:

startPosition = RichTextBox1.Text.IndexOfAny(New Char() {"A"c, "a"c,
"U"c, "u"c})

--
G?ran Andersson
_____
http://www.guffa.com


Ron wrote:

I am getting an error Option strict on disallows implicit conversion
from string to long

I get it for this code

iStartPosition = InStr(iStartPosition + 1, RichTextBox1.Text, "A" Or
"a"

the "A" and "a" are underlined in blue. How can I fix this?

Say I want it to be:
iStartPosition = InStr(iStartPosition + 1, RichTextBox1.Text, "A" Or
"a" Or "U" or "u" etc

how can I make this work?

Hello Ron, I thought you would have posted back into the original
thread(??), but anyway, to achieve what you''re asking just change the
line to the following -

iStartPosition = InStr(iStartPosition + 1, RichTextBox1.Text, "AU-",
CompareMethod.Text)

Note, all I''ve added is the "CompareMethod.Text"
ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don''t.


G?ran Andersson wrote:

>
You can use the IndexOfAny method to find one of many characters:

startPosition = RichTextBox1.Text.IndexOfAny(New Char() {"A"c, "a"c,
"U"c, "u"c})

G?ran, Ron is getting a bit confused here. He is actually trying to
find all occurrences of "AU-", "au-", "Au-" or "aU-". If he finds any
A''s or U''s he''ll also find A''s & U''s in other areas of his text, which
isn''t what he originally claimed he wanted.

Please see his original post - "How would I do this??"
ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don''t.


这篇关于如何将此字符串修复为长错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆