[英]Sync Two Textbox Lines VB.Net
How do I sync 2 Textboxes? 如何同步2个文本框? I mean, if I randomize the first Textbox (Randomize Text Lines) how do the 2nd Textbox be synchronized after the first Textbox? 我的意思是,如果我随机化第一个文本框(随机化文本行)如何在第一个文本框之后同步第二个文本框?
I also want the 4 Textboxes containing the items to be saved in (Answer.dat) for example if in the first Textbox I have the element (BlackJack) in the 2nd Textbox element (21) in the 3rd Textbox the Poker element and the fourth Textbox element Bingo. 我还想要包含项目的4个文本框保存在(Answer.dat)中,例如,如果在第一个文本框中我在第3个文本框中的第2个文本框元素(21)中有元素(BlackJack),则扑克元素和第4个文本框文本框元素宾果。
I want to save this in the new line (in my text file) to be something like the model (Blank Empty + Word(Textbox3) + Space + Word(Textbox4) + Space + Word(Textbox5) + Space + Word(Textbox6) this is the Screenshot how the items want to be saved. Unfortunately, I'm not doing too well with the blank at first. 我想在新行(在我的文本文件中)保存这个类似于模型(空白空白+ Word(文本框3)+空格+单词(文本框4)+空格+单词(文本框5)+空格+单词(文本框6)这是截图如何保存项目。不幸的是,我一开始并没有做好空白。
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = System.IO.File.ReadAllText(My.Application.Info.DirectoryPath + ("\Data\Question.dat"))
TextBox2.Text = System.IO.File.ReadAllText(My.Application.Info.DirectoryPath + ("\Data\Answer.dat"))
End Sub
End Class
So how can I do to save in a new line of Textbox (Save to my text file) the question and the answers in the textbox? 那么如何在文本框中保存新文本框(保存到我的文本文件)中的问题和答案呢? following the example given? 按照给出的例子?
The code below will keep the rows synchronized on a random shuffle. 下面的代码将使行在随机shuffle上保持同步。 If you don't want repeated rows, you will have to code validation to throw-out draws that have already occurred. 如果您不想重复行,则必须对已经发生的抛出绘制进行代码验证。
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim text1 As String
Dim text2 As String
Dim textarray1 As New ArrayList
Dim textarray2 As New ArrayList
Dim NextMember As String = ""
Dim Rand As New Random
Dim RandNum As Integer = 0
TextBox1.Clear()
TextBox2.Clear()
text1 = "one" & vbCrLf & "two" & vbCrLf & "three" & vbCrLf
text2 = "A" & vbCrLf & "B" & vbCrLf & "C" & vbCrLf
For i = 1 To Len(text1)
Do Until Mid(text1, i, 1) = vbCr
NextMember = NextMember & Mid(text1, i, 1)
i = i + 1
Loop
textarray1.Add(NextMember)
i = i + 1
NextMember = ""
Next
For i = 1 To Len(text2)
Do Until Mid(text2, i, 1) = vbCr
NextMember = NextMember & Mid(text2, i, 1)
i = i + 1
Loop
textarray2.Add(NextMember)
i = i + 1
NextMember = ""
Next
For i = 0 To textarray1.Count - 1
RandNum = Rand.Next(textarray1.Count)
TextBox1.Text = TextBox1.Text & textarray1(RandNum) & vbCrLf
TextBox2.Text = TextBox2.Text & textarray2(RandNum) & vbCrLf
Next
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.