[英]How can I randomize all lines in a TextBox?
I want to randomize all lines in TextBox.Text
.我想随机化TextBox.Text
所有行。
But my code is randomizing the values in the array myStrings()
only.但我的代码只是随机化数组myStrings()
的值。 What I want to do is randomize all lines in TextBox.Text
.我想要做的是随机化TextBox.Text
所有行。
Here's my code:这是我的代码:
Dim myRnd as New Random
Dim myStrings() As String = {dfasdht,agaskhga,twrtwert}
Textbox1.Text = myStrings(myRnd.Next(3))
Here's an example of what TextBox.Text
should start with:下面是TextBox.Text
应该以什么开头的示例:
sample1
sample2
sample3
And end with:并以:
sample2
sample1
sample3
Dim rng As New Random
'Get the current lines into an array.
Dim lines = TextBox1.Lines
'Randomise the array.
lines = lines.OrderBy(Function(line) rng.NextDouble()).ToArray()
'Put the randomised data back into the control.
TextBox1.Lines = lines
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.