重复的数字 [英] Repeated numbers
问题描述
嗨。
我正在尝试编写一个布尔函数来检查用户是否输入了一个7个相等数字的序列,例如:1111111, 2222222,33333333
等等。我怎么能在VB.NET中做到这一点?
谢谢,
Robert Scheer
Hi.
I am trying to write a boolean function that checks if the user
entered a sequence with 7 equal numbers, eg: 1111111, 2222222, 3333333
and so on. How can I do this in VB.NET ?
Thanks,
Robert Scheer
推荐答案
" Robert Scheer" < rb ****** @ my-deja.comschrieb
"Robert Scheer" <rb******@my-deja.comschrieb
嗨。
我想写一个布尔函数,用于检查用户是否输入了7个相等数字的序列,例如:1111111,2222222,
3333333等等。我怎么能在VB.NET中做到这一点?
Hi.
I am trying to write a boolean function that checks if the user
entered a sequence with 7 equal numbers, eg: 1111111, 2222222,
3333333 and so on. How can I do this in VB.NET ?
Dim s As String =" 1111111"
Dim b As Boolean
b = _
s.length = 7 _
andalso _
Array.TrueForAll(s.ToCharArray,Function(c As Char)(c = s(0)))
(VB 2008)
Armin
Dim s As String = "1111111"
Dim b As Boolean
b = _
s.length = 7 _
andalso _
Array.TrueForAll(s.ToCharArray, Function(c As Char) (c = s(0)))
(VB 2008)
Armin
" Armin Zingler" < az ******* @ freenet.dekirjoitti viestiss?
新闻:eO ************** @ TK2MSFTNGP04.phx.gbl ...
"Armin Zingler" <az*******@freenet.dekirjoitti viestiss?
news:eO**************@TK2MSFTNGP04.phx.gbl...
" Robert Scheer" < rb ****** @ my-deja.comschrieb
"Robert Scheer" <rb******@my-deja.comschrieb
>嗨。
我正在尝试写一个布尔值用于检查用户是否输入了7个相同数字的序列的函数,例如:1111111,2222222,
3333333等。我怎么能在VB.NET中做到这一点?
>Hi.
I am trying to write a boolean function that checks if the user
entered a sequence with 7 equal numbers, eg: 1111111, 2222222,
3333333 and so on. How can I do this in VB.NET ?
另一种解决方案:
Dim a As String =" 1111111"
Dim b As Boolean = False
b = a.Length = 7 AndAso a.Replace(a.Substring(0,1),"")=""
不需要VB 2008.
-Teemu
Another solution:
Dim a As String = "1111111"
Dim b As Boolean = False
b = a.Length = 7 AndAlso a.Replace(a.Substring(0, 1), "") = ""
Doesn''t need VB 2008.
-Teemu
" Teemu"写道:
"Teemu" wrote:
>
" Armin Zingler" < az ******* @ freenet.dekirjoitti viestiss?¤
新闻:eO ************** @ TK2MSFTNGP04.phx.gbl .. 。
>
"Armin Zingler" <az*******@freenet.dekirjoitti viestiss?¤
news:eO**************@TK2MSFTNGP04.phx.gbl...
" Robert Scheer" < rb ****** @ my-deja.comschrieb
"Robert Scheer" <rb******@my-deja.comschrieb
嗨。
我想写一个布尔函数,用于检查用户是否输入了7个相等数字的序列,例如:1111111,2222222,
3333333等等。我怎么能在VB.NET中做到这一点?
Hi.
I am trying to write a boolean function that checks if the user
entered a sequence with 7 equal numbers, eg: 1111111, 2222222,
3333333 and so on. How can I do this in VB.NET ?
另一个解决方案:
Dim a As String =" 1111111"
Dim b As Boolean = False
b = a.Length = 7 AndAso a.Replace(a.Substring(0,1),"")=""
不需要VB 2008.
-Teemu
Another solution:
Dim a As String = "1111111"
Dim b As Boolean = False
b = a.Length = 7 AndAlso a.Replace(a.Substring(0, 1), "") = ""
Doesn''t need VB 2008.
-Teemu
但是这两个代码对于字符串AAAAAAA评估为真。我猜
原始海报应该有一些有趣的捕获这种情况。
But both of these codes evaluate to true for the string "AAAAAAA". I guess
the original poster should have some of the fun catching this case.
>
>
这篇关于重复的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!